Animation won't work for some reason

Ok so I’m making a mining game and I want to add an mining animation. The animation is in the tool. The animation was on the client side, and I fired it to the server side. By the way, this is a server script and the script was in the tool. Here’s the code:

wait(1)
local day = game.Players:FindFirstChild(script.Parent.Parent.Parent.Name).Character.Humanoid:LoadAnimation(script.Parent.MiningAnimation)
print(script.Parent.Parent.Parent.Name)

game.ReplicatedStorage.AnimationLoader.OnServerEvent:Connect(function(Player, Pick,PlayStop)
	print("FIRED")
	if Pick == script.Parent then
		print("IsPick")
		if PlayStop == true then
			print("ShouldPlay")
			day:Play()
		else
			print("ShouldStop")
			day:Stop()
		end
			
		
	end
end)

It should work, but it doesn’t. It doesn’t play the animation at all. It is firing and doing the correct things, but it’s not playing the animation. I have no idea why.

1 Like

It’s because this is only seen by the client…? Are you sure that the animation is parented to the tool?

This is. This is a server script and it is being fired by a local script.

And the animation is action priority.

Is this a script or a local script?

It’s a script. But it’s being fired by a localscript.

Can I see the local script? It may be something in there

Oh I see your issue, you are trying to fire the animation from a server script. Since animations transfer from client to server you have to play it from a local script. You can’t play a animation from the server side, it has to be on the clients side.

No, you can play animations through the server too.

Humanoid:LoadAnimation is deprecated, see

If it’s depreciated, than what should I use? I’ve used loadanimation before, about the same way now. But for some reason, it doesn’t work this time.

What would you use today? I also had some problems with my animations lately.

I just linked you to Animator:LoadAnimation(), it’s what you should use instead

Animations run on Local scripts and it does run on the server and client when fired through a local script.

Try playing it from a local script. It is easier to do it from a local script.

No, for my moves I run animations through the server to communicate with GetMarkerReachedSignal, it works

I did. Still does nothing though.

Here’s some example code

	local function playAnimationFromServer(character, animation)
		local Humanoid = playerWhoFired.Character:FindFirstChildOfClass("Humanoid")
		if Humanoid then
			local animation = script.Animation
			local animator = Humanoid:FindFirstChildOfClass("Animator")
			if animator then
				local animationTrack = animator:LoadAnimation(animation)
				animationTrack:Play()

Here’s what the client side looks like:

script.Parent.Unequipped:Connect(function()
	Animation:Stop()
	game.ReplicatedStorage.AnimationLoader:FireServer(script.Parent,false)
end)

Mouse.Button1Down:Connect(function()
game.ReplicatedStorage.AnimationLoader:FireServer(script.Parent,true)
Animation:Play()
end)