Tool Animation Not Playing

Hey, developers! :wave:

I’ve been developing my game for a few weeks, and one thing I’ve been looking forward to the absolute most is the tools, but more so the tool animations!

The problem is, whenever I test the tool’s animation, it doesn’t seem to work! The script doesn’t error, and everything is correctly written (I believe), so if anyone knows the issue, please let me know! :smiley:

Code:

local Anim = script.Parent.IK_ANIM
local Player = game.Players.LocalPlayer

script.Parent.Activated:Connect(function()
	local Humanoid = Player.Character:FindFirstChildOfClass('Humanoid')
	local Animation = Humanoid:LoadAnimation(Anim)

	Animation:Play()
end)

This is a LocalScript under the tool! (I originally set it as a script and got the player another way, but that script didn’t work, so I changed it to a LocalScript, and changed the way of getting the player, which obviously didn’t work-)

Thanks in advance! :grin:

1 Like

I think the issue here is your trying to load animations on the client which doesn’t work I believe.

It didn’t work on the server either, which is even more confusing- :thinking:

Are you sure the animation exists and has the correct priority set? I believe it needs to be set to action.

Yep, yep, and yep!

All of the settings were correct, and it was uploaded and all! The actual code is the problem, which is really confusing-

Does this print any error?
Player.Character might not exist yet when you are activating the tool.

Nope, no errors, and I made sure the character was loaded before I activated it.

Try and test the animation normally without it being activated by a tool, also for more bug testing add prints between every line and see if they print

So when testing, I found it doesn’t even activate, which is very interesting-

Any idea why? There is a handle and all, so I don’t get why this would be happening!

Is it a server script or local?

I changed it to a server script.

The activated event isn’t firing, which may be the cause of this. I’ll try something else that might work!

I just doubled checked and I think you can load animations on the client, though this has been buggy for me in the past. Though I would stick to a local script since that’s what I’ve been using in my recent game.

Try this out!
LocalScript

local Anim = script.Parent:WaitForChild("IK_ANIM")
local Player = game.Players.LocalPlayer

script.Parent.Activated:Connect(function()
	local Character = Player.Character or Player.CharacterAdded:Wait()
	local Humanoid = Character:FindFirstChildOfClass('Humanoid')
	local Animation = Humanoid:LoadAnimation(Anim)

	Animation:Play()
end)

Perhaps would a WeldConstaint be an issue here?

Try this code

local Anim = script.Parent:WaitForChild("IK_ANIM")
local Tool = script.Parent

Tool.Activated:Connect(function()
 local Character = Tool.Parent
 local Humanoid = Character:WaitForChild('Humanoid')
 local Animation = Humanoid:LoadAnimation(Anim)

Animation:Play()
end)

That could be, but I highly doubt it. I would double-check if the character and humanoid both exist and the animation too.

Actually animations are recommended to be played on the client.

Yeah that’s true, though I’m not sure what the error is here.

local PS = game:GetService("Players");
local Anim = script.Parent:WaitForChild("IK_ANIM");
local Player = PS.LocalPlayer;
local Character = Player.Character or Player.CharacterAdded:Wait();
local Humanoid = Character:FindFirstChildOfClass("Humanoid");
local Animator = Humanoid:FindFirstChildOfClass("Animator");

script.Parent.Activated:Connect(function()
	if Humanoid and Animator then
		local Animation = Animator:LoadAnimation(Anim)
		Animation:Play()
	end
end)

Animations are recommended to be played through the Animator nowadays, make sure the animation is uploaded to the game’s creators profile, or if it is a group game, upload it to the group.

Run this as a Localscript inside your tool.

Just mentioned this in my last post, I honestly still think that the old animation system was better without any issues.