Playing animations through the server

Right now I want npcs to play idle animations when the server gets created, but when I try to do it through a server script, no one can see it except for the server. I don’t really want to do it through a local script since animations played from a local script get replicated over to the server. I noticed that when I copy and paste all the code from the Animate local script that characters automatically load in with into a server script and parent the script to an npc, the animations would play perfectly fine, but I don’t really know how this works.

you probably want to do it via local script also what do you mean it gets replicated over to the server?

Playing them on the client is mainly for player characters.
Playing them on the server is mainly for other things like npcs.

Client animations get replicated but only when played on player characters. Server animations will always replicate to all clients.

If you are playing animations for npcs, then you want to play them on the server. Any problems you might be facing likely aren’t caused by replication.

6 Likes

When I play an animation from a local script on a character, the animation would play on the character and everyone else would see it.

After doing a little more looking into I saw that the animations were being replicated over from server to client. The problem was that I looped the animationtrack in the server script instead of through the animation editor, and so when I would be able to reach the animated npc, the animation would have already ended once the player got there, where it wouldn’t loop because the animation itself isn’t looped.

1 Like