How can I make client animations play for others?

Hey there! I’m trying to make a hold script for a tool, but it’s only playing the animation to the client, not the server. I’m using a local script for this hold animation… I heard that with a local script, it will replicate the animation to the server so I don’t know what’s the issue here. I’ve tried using a server script for creating the instance and I’ve tried using a running the animation on it as well with no luck. Any solutions?

Code:

local tool = script.Parent
local equipAnim = Instance.new("Animation")
equipAnim.AnimationId = "rbxassetid://5673888071"

tool.Equipped:Connect(function()
	local equipTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(equipAnim)
	equipTrack.Priority = Enum.AnimationPriority.Action
	equipTrack.Looped = true
	equipTrack:Play()
end)
1 Like

Client animations already play for everyone. There is no need to try to change your script.

1 Like

A local script will only play on your client. things like killing a character deleting, adding, or doing most anything or a local script will not work on the server. If you want to play an animation on the server side then I suppose you use a remote events.

here is what you should do:

--place a local script for when your character is holding the tool:

local tool = script.Parent
local equipAnim = Instance.new("Animation")
equipAnim.AnimationId = "rbxassetid://5673888071"

tool.Equipped:Connect(function()
	 
      --now instead add a remote event into game.ReplicatedStorage and name it playAnim:

      --we will now FIRE (call) the event:

      game.ReplicatedStorage.playAnim:FireServer(equipAnim,game.Players.LocalPlayer.Character.Humanoid)

    -- make sure it is fire server and nothing else

end)

now insert a normal script into game.ServerScriptService and write this in it:

game.ReplicatedStorage.playAnim.OnServerEvent:Connect(function(Player, Animation, Humanoid)

       local equipTrack = Humanoid:LoadAnimation(equipAnim)
	equipTrack.Priority = Enum.AnimationPriority.Action
	equipTrack.Looped = true
	equipTrack:Play()

end)
1 Like

Remote events are pointless in this situation as tool animations from the client should replicate automatically.

1 Like

So would this be a glitch of some sort perhaps?

I’m having the exact same problem, at the exact same time, so it’s not impossible.

1 Like

When I tried using remote events it worked perfectly!
the server and my client could see the animation!

The character’s position should replicate anyways. (Including animations)

1 Like

Well it could be an issue with the animation itself. Make sure that you own the animation, and that the animation is uploaded properly (i.e. load it in the animation editor and see if everything is right).

Other than that, I don’t know. You could try yielding for the player’s character to make sure it exists and everything is in place.

If all else fails try running it completely on a server script and if that works then we might have an issue here because it is supposed to replicate.

1 Like

Would there happen to be a fix for this issue?

1 Like

Pretty much just try and debug. Make sure the local script is running and that it gets to that line of code. Make sure the normal default animation script works. Try running an animation from the command line maybe.

If it works on the server but not on the client then you can just have your animations server side worst case scenario

1 Like

Thanks @SSSpencer413! Reuploaded my animation and did some tinkering. It works fine now.

1 Like