Do I play animations on the server or the client?

Simple question, If I want to have a humanoid animation be played by one person, and have if also be visible on every player on the server, do I play it on a server or client script?

By client script, I mean every single client will play the animation but only the player who used the ability will have the animation played on their humanoid, since client scripts can access every player. However, if I play it on the server, I could just play the animation on the humanoid??

I would recommend using a local script to play it (assuming this animation is being played on the clients character)

Why you ask?

Well how roblox works, a lot of changes a client makes too its character replicate to the server and other players. This is cause of NetworkOwnership, which by default, the player has network ownership of their character.

So in short, if you play a animation from a local script onto your character, it will replicate to the server.


Hope this helps :D

1 Like

???

Literally just use a RemoteEvent and connect it to this on the Server: Humanoid:LoadAnimation(animation):Play()

Longer Version:

-- LocalScript:

local RemoteEvent = -- your remote event

local function FireAnimation()

RemoteEvent:FireServer()

end

-- Connect FireAnimation() to whatever you want.
--Script
local RemoteEvent = -- your remote event
local Animation = -- your animation

RemoteEvent.OnServerEvent:Connect(function(player)
local Character = player.Character
local Humanoid = player:WaitForChild("Humanoid")

local animationTrack = Humanoid:LoadAnimation(Animation)
animationTrack:Play()
end)

I’m sure that there is a better way to do this, so I’ll let other Forum users correct me.

EDIT: You don’t have to use a function to fire the RemoteEvent, I just wanted to make it easier for any new scripter who might need it! :smile:

So idk what this is from, but I dont think its correct? I might be wrong, but I have reason to believe otherwise.

I read somewhere the things I’ve said, but that isnt very good proof. Thats when I thought of the actual character of a player. It has a local script inside of it called animations, all animations played via it are seen by all players from the look of it, which leaves me with reason to believe that the changes you make to an object you have NetworkOwnship of will replicate to the server and other clients.

Im also pretty sure this is right, as I’ve seen exploiters play animations that arent in the game, how? Their just loading said animation onto their client. That or the devs just made a remote event that allows you to load and play any animation you want, which I doubt, so thats my guess :D

I have zero idea why one guy is fully trusting Chat GPT and the other is telling you to use remote events, but play animations on the client. @FroDev1002 is the only actually correct one to respond here.

When it comes to player characters, animations are replicated. If you were to look at the official roblox animate script, you’ll see that it is a local script with ZERO remote events. And I do believe that FroDev yet again, gave the correct explanation with Network Ownership.

The only case where I can ever think you may have to play animations on the server is when its 100% neccessary to get 2 different animations on 2 different characters to sync perfectly.

However, if you wanted the animation to play purely locally, you could probably save each keyframe and then manually set the C0 property of each limb via a local script, as that doesn’t replicate.

3 Likes

ok so from what im seeing, as long as I’m using the animator object under humanoid, animations will auto replicated like physics

1 Like

My dude, why da hell are you asking ChatGPT :skull:

1 Like

Sometimes it knows what its talking about, definitely not this time though

they replicate, robloxs animate script is local and it plays the emotes and stuff., i made my own localscript to play animations and it was showing on the server too.