Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why won't this animation/weld localscript work?

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

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.