Animation tool script won't work

I have a server script with the RunContext set to client, but this script isn’t working. I have another tool with this exact same script that works fine, but this one seems to not. The only thing in the dev console is “Attempt to index nil with :WaitForChild()”, but that doesn’t seem to matter since the other tool works fine.

local animation = script.Parent.Parent:WaitForChild("TabletAnimation")
local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local track = animator:LoadAnimation(animation)

script.Parent.Parent.Equipped:Connect(function()
	track:Play()
end)

script.Parent.Parent.Unequipped:Connect(function()
	track:Stop()
end)

script.Parent.Parent.Destroying:Connect(function()
    track:Stop()
end)

Any help would be appreciated.

1 Like

does the tool have ‘RequiresHandle’ set to true? This might be causing the issue

1 Like

Yes, but the other tool has it enabled aswell and it works fine.

1 Like

Is the other one also a server script running under the client context?

1 Like

Yes, it uses the exact same script except for the names, which are different

Working Tool:
local animation = script.Parent.Parent:WaitForChild("TabletAnimation")
local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local track = animator:LoadAnimation(animation)

script.Parent.Parent.Equipped:Connect(function()
	track:Play()
end)

script.Parent.Parent.Unequipped:Connect(function()
	track:Stop()
end)

script.Parent.Parent.Destroying:Connect(function()
    track:Stop()
end)
Non-Working tool:
local animation2 = script.Parent.Parent:WaitForChild("KitAnim")
local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local track = animator:LoadAnimation(animation2)

script.Parent.Parent.Equipped:Connect(function()
	track:Play()
end)

script.Parent.Parent.Unequipped:Connect(function()
	track:Stop()
end)

script.Parent.Parent.Destroying:Connect(function()
    track:Stop()
end)

Pretty sure I found the problem, the script isn’t running. Not sure why though. Does anyone know?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.