Playing animation on tool click

Hello, Im trying to play animation on tool click, but its not working and I don’t really know why.
No errors on console, just nothing.

Here is the local script:

wait(5)

local Player = game.Players.LocalPlayer

local Character = Player.Character

local Humanoid = Character:WaitForChild("Humanoid")

local animation = Humanoid:LoadAnimation(script.Parent.Animation)



script.Parent.Activated:Connect(function()
	animation:Play()	
end)

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

2 Likes

can u show the explorer where there is the animation if you can

Maybe this works

wait(5)

local Player = game.Players.LocalPlayer
local Character = workspace:WaitForChild(Player.Name)

local Humanoid = Character:WaitForChild("Humanoid")

animation=Humanoid:LoadAnimation(script.Parent.Animation)

function onActivation()
	animation:Play()	
	print("Playing")
end

script.Parent.Activated:Connect(onActivation)

script.Parent.Unequipped:Connect(function()
	animation:Stop()
	print("Stopped")
end)
1 Like

Use Humanoid.Animator:LoadAnimation
Why? Nothing in particular, just that Humanoid:LoadAnimation is deprecated.

Also for the character use Player.Character, it gets the character for you no problem.

Is the animation’s priority set to action? If it’s set to core it won’t play as it gets overwritten by your character’s base animations.

To change its priority simply open the animation editor, import the animation and in settings select animation priority.

3 Likes