|
| 07 Mar 2012 02:14 PM |
I'm looking for a weld script that will hold C-framed bricks together for my gun. This one won't work:
c = script.Parent:getChildren() for a = 1, #c do if c[a].Name ~= "Handle" and c[a].className == "Part" then value = Instance.new("CFrameValue") value.Parent = script.Parent.Handle value.Name = (c[a].Name.."CF") value.Value = c[a].CFrame:inverse()*script.Parent.Handle.CFrame end end
function weld() c = script.Parent:getChildren() for a = 1, #c do if c[a].className == "Part" and c[a].Name ~= "Handle" then weld = Instance.new("Weld") weld.Parent = script.Parent.Handle weld.Part0 = weld.Parent weld.Part1 = c[a] weld.C1 = script.Parent.Handle[c[a].Name.."CF"].Value end end end
script.Parent.Equipped:connect(weld) weld()
c = script.Parent:getChildren() for a = 1, #c do if c[a].className == "Part" then c[a].Anchored = false end end
Im using 4 total parts for my gun. A handle,hole,and two pats. Please respond |
|
|
| Report Abuse |
|
|
|
| 07 Mar 2012 03:16 PM |
function stick(x, y) weld = Instance.new("Weld") weld.Part0 = x weld.Part1 = y local HitPos = x.Position local CJ = CFrame.new(HitPos) local C0 = x.CFrame:inverse() *CJ local C1 = y.CFrame:inverse() * CJ weld.C0 = C0 weld.C1 = C1 weld.Parent = x end
stick(MainPart,YourPartYouWantWelded)
make sure you make the x of the function the main part you want all of the other parts (the y) to be welded to |
|
|
| Report Abuse |
|
|
|
| 07 Mar 2012 05:10 PM |
| Will this work for my gun? |
|
|
| Report Abuse |
|
|