Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't this animation/weld localscript work?

Asked by 10 years ago

This localscript weld animation thing doesn't work when i walk but if i don't walk it works. Whats the problem? Anyone?

gun = script.Parent
Player = game.Players.LocalPlayer
la = Player.Character:FindFirstChild("Left Arm")
t = Player.Character:FindFirstChild("Torso")
rs = Player.Character.Torso:FindFirstChild("Right Shoulder")
ls = Player.Character.Torso:FindFirstChild("Left Shoulder")

local function weldBetween(a, b)
    local weld = Instance.new("Weld")
    weld.Part0 = a
    weld.Part1 = b
    weld.C0 = CFrame.new()
    weld.C1 = b.CFrame:inverse() * a.CFrame
    weld.Parent = a
    return weld;
end

function localequipped()
    weldBetween(la, gun.Handle)
    rs.C0 = rs.C0 *CFrame.new(0.5,1,0)
    ls.C0 = ls.C0 *CFrame.new(0,5,4.75)

end
gun.Equipped:connect(localequipped)
function localunequipped()
    laweld = la:FindFirstChild("Weld")
    laweld:Destroy()
    rs.C0 = rs.C0 *CFrame.new(-0.5,-1,0)
    ls.C0 = ls.C0 *CFrame.new(0,-5,-4.75)

end
gun.Unequipped:connect(localunequipped)

1 answer

Log in to vote
0
Answered by
iaz3 190
10 years ago

I believe this is because you are connecting to the shoulders located in the torso.

Roblox has it's own animations as you should know. You appear to be relying on the shoulders to not change, but they will, and do. For example when you walk, or jump, or do anything.

Ad

Answer this question