Animation not playing

I am making a game with weapons, and I want an idle animation to play while the weapon is equipped, but it won’t play. This code is inside of a local script

while script.Parent.Equipped == true do
	wait(1)
	local animation = script.Parent:WaitForChild('Idle')
	local humanoid = script.Parent:WaitForChild('Humanoid')
	local idle = humanoid:LoadAnimation(animation)
	idle:Play()
end
1 Like

load into this local Animator = humanoid:WaitForChild(“Animator”)

1 Like

Still won’t work

while script.Parent.Equipped == true do
	wait(1)
	local animation = script.Parent:WaitForChild('Idle')
	local humanoid = script.Parent:WaitForChild('Humanoid')
	local animator = humanoid:WaitForChild("Animator")
	local idle = animator:LoadAnimation(animation)
	idle:Play()
end
1 Like

make sure the script is running in the first place. Use print statement.

1 Like

It isn’t even running and I don’t know why

Your loop will not start if the condition inside is false at runtime. This is probably the behavior you’re looking for:

1 Like