How to make client animation play server-sided?

So I have a custom animation play whenever a player clicks on their tool client sided. It works perfectly the client can see the animation. When I attempt to play the animation server-sided through events(I would like other players to see each other’s animations) the animation does not play at all on the server. How would I go about making the animation play from the server?

local humanoid = char:WaitForChild("Humanoid")
local HammerAnimation = Instance.new("Animation")
HammerAnimation.AnimationId = "http://www.roblox.com/asset/?id=3517445652"

local anim = humanoid:LoadAnimation(HammerAnimation)
anim.Priority = Enum.AnimationPriority.Action

script.Parent.Activated:Connect(function()
if not clicked then
	clicked = true
	playerClick:FireServer()
	anim:Play()
	wait(clickDelay)
	clicked = false
end
end)

Edit: Added local script that is handling the animation in the tool

3 Likes

I thought animations replicate from client to server. :thinking:


If that doesn’t work. Go for a server-sided animation script(not sure) which uses Humanoid:LoadAnimation() to set up an AnimationTrack. The AnimationTrack can be played later on as if they were a sound.

Just use AnimationTrack:Play() in order to play the animation.

2 Likes

Animations loaded and played by a client script will replicate across the server, I literally did this yesterday.

Are you receiving any errors in the output window?..
Have you tried placing Print statements through the ‘Activated’ method to see if your code is running?

When I was loading my animations, I used the following path:

HammerAnimation.AnimationId = "rbxassetid://3517445652"
1 Like

Not a single error and I did that everything is working great other than the animation not replicating for some reason. I tested in a live game too with a separate computer and still the animation wasn’t replicating. This is the strangest thing that has happened to me in a while. I really have no other ideas on how to solve this. I went ahead and created an entire new place to test it there and it still wouldn’t replicate so I must be doing something wrong.

I just completely made it so that when playerClick:FireServer() is called it creates the animation, parents it to the Player’s character, loads it into the humanoid and then plays it. Now it plays ONLY for the server and doesn’t even replicate from the server to client which is sooooo confusing.

I went searching across the forum. Animations not replicating from client is a similar question about why the animation is not replicating from the client.

What I think you need to do is to create the animation instance on server and let the client read the animation instance there. Perhaps this will fix the issue?

1 Like

Make sure that any basepart isn’t anchored. Also please print out the network owner of your characters baseparts.

Try setting the priority in the animation editor instead.

2 Likes

Setting the priority in the animation editor instead of the script worked, the animations now replicate. Is this a bug? Do you know what is going on with that and why it does that? Thank you lots!

It’s not really s bug, or atleast I don’t think so.