giftbox24
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 20629 |
|
|
| 23 Aug 2014 05:36 PM |
I looked at the wiki on weapon welding and it gave me something in this format. (I changed some numbers and part names)
function Weldnow() local w1 = Instance.new("Weld") w1.Parent = script.Parent.Handle w1.Part0 = w1.Parent w1.Part1 = script.Parent.Wedge1 w1.C1 = CFrame.Angles(0, 0, 0) * CFrame.new(0, -5.5, 0.2) local w2 = Instance.new("Weld") w2.Parent = script.Parent.Handle w2.Part0 = w1.Parent w2.Part1 = script.Parent.Wedge2 w2.C1 = CFrame.Angles(0, -4, 0) * CFrame.new(0, -5.5, -0.2) end script.Parent.Equipped:connect(Weldnow) script.Parent.Unequipped:connect(Weldnow)
But this is really unwieldy. I've got to equip the weapon, search for it in explorer, edit the script, disable and re-enable the script, and re equip the weapon. Even then, one of the blocks might not be at the desired angle. And the numbers are really weird too. The blocks are usually like 1 degree off from what I wanted.
So I took a script from this guy, Gybron. Pretty useful, you just build the weapon the way you want it to look and put this script in the tool. It welds really well.
function Weld(x,y) local W = Instance.new("Weld") W.Part0 = x W.Part1 = y local CJ = CFrame.new(x.Position) local C0 = x.CFrame:inverse()*CJ local C1 = y.CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = x end
function Get(A) if A.className == "Part" then Weld(script.Parent.Handle, A) A.Anchored = false else local C = A:GetChildren() for i=1, #C do Get(C[i]) end end end
function Finale() Get(script.Parent) end
script.Parent.Equipped:connect(Finale) script.Parent.Unequipped:connect(Finale) Finale()
Unfortunately, tiny wedges don't seem to hold. When I equip a weapon, the wedges appear before the rest of the weapon does, and they drop to the ground.
Maybe the roblox scripting wiki's scripts are out of date. Or I'm just not understanding the cframing numbers. Is there an easier way to weld weapons? |
|
|
| Report Abuse |
|
giftbox24
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 20629 |
|
| |
vat21s
|
  |
| Joined: 07 Jun 2010 |
| Total Posts: 2508 |
|
| |
|
| 23 Aug 2014 07:51 PM |
The reason you get wedges falling to the ground is because the weld script doesn't recognise them as parts. This should work:
function Weld(x,y) local W = Instance.new("Weld") W.Part0 = x W.Part1 = y local CJ = CFrame.new(x.Position) local C0 = x.CFrame:inverse()*CJ local C1 = y.CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = x end
function Get(A) if A.className == "Part" or if A.className == "WedgePart" then — This line only had "part" as a valid weldable object Weld(script.Parent.Handle, A) A.Anchored = false else local C = A:GetChildren() for i=1, #C do Get(C[i]) end end end
function Finale() Get(script.Parent) end
script.Parent.Equipped:connect(Finale) script.Parent.Unequipped:connect(Finale) Finale() |
|
|
| Report Abuse |
|