Animation won't play when tool is equipped

Hello!

I am trying to play an animation when the user activates a tool. It prints to the console “Hello World”, but the animation won’t play.

I then tried putting the script alone and trying to make it run at server start, it worked, then I did that same thing but equipped the tool before the animation was supposed to play and it didn’t play.

How could I fix this?

My code:

function onActivated()
	print("Playing Animation")
	local player = game.Players.LocalPlayer
	local Animation = Instance.new("Animation", player.Character)
	Animation.AnimationId = "rbxassetid://myAnimationID"
	local AnimationLoaded = player.Character.Humanoid:LoadAnimation(Animation)
	AnimationLoaded:Play()
end

script.Parent.Activated:Connect(onActivated)

I replaced my animation ID with “myAnimationID”.

Thanks in advance

1 Like

You need to show your code in order for us to help you. Please edit your thread to include it.

2 Likes

I edited my post to include my code.

The problem is most likely that you haven’t filled in an actual animation to play:

Animation.AnimationId = "rbxassetid://myAnimationID"

myAnimationID should be replaced with an actual animation ID.

1 Like

There is a real animation ID in there, I just prefered to hide it on my code sample.

But your code says:

I’m guessing this is a typo?

1 Like

Basically, it didn’t say “Hello World”, it was just an example text but in the code there was written “Playing Animation”. It’s my habit of telling that code outputs hello world ¯\_(ツ)_/¯

Is your animation priority higher than Core?

2 Likes

Since I don’t know alot about animations, here’s a screenshot of the “Animation Priority”image

Try to set it as Movement and then overwrite it.

7 Likes

That solves my problem! Thanks you alot!

1 Like