I want to ask about how can I stop the animation on the server side? I have try to use get anim track to get all the anim track of a character and stop it. However, the result is it only stop the animation on the server side only. And you can see the animation is still playing on the client side. This is why I want to ask how to stop animation on server side or is it even possible?
Another lite question is can server side stop a looping animation?
I will very happy if any help can be provided, thank you!
First of all, you should probably be playing animations on the client unless you have a reason not to.
FireAllClients() with the animation or other information.
This is better not only for visual appearance, but also because of one simple fact:
When an animation is played on the server, each client will have to produce the animation on their view nonetheless.
This means that playing animations on the client is generally the same thing / if not faster.
The issue is that the client and server have a independent-dependent relationship. However, I suspect there is simply an issue in your code.
Oftentimes things you’d expect to sync do not sync and vice versa.
Animations are synced, but each client might display different based on lag or other factors.
Nonetheless, the issue is likely an error in your code.
However, because you asked for server-side solution, here is a fully server-side code for this:
local player = [assume player is defined]
local humanoid = player.Character:FindFirstChild("Humanoid") -- retrieve humanoid
local animator = humanoid:FindFirstChildOfClass("Animator") -- animator is a descendent of all player humanoids
local animation = Instance.new("Animation") -- you could also retrieve an existing animation somewhere
animation.AnimationId = "rbxassetid://YOUR_ANIMATION_ID" -- you need to set ID since its a new instance
--[NOTE] we did not set a parent! this instance doesn't need a parent because we only need its existence to run animations
local track = animator:LoadAnimation(animation) -- using the animation object, load the animation into a "track", which is used to play animations
track:Play() -- play the track, it is already loaded to the player
task.wait(3) -- wait 3 seconds, use task.wait as its more efficient
track:Stop() -- stop the track
I suspect the issue you had was likely not storing the track into a variable.
When you don’t store the track as a variable, you are creating a new ‘track’ every time.
By storing it, you have one track that can be controlled.
But I did use :GetPlayingAnimationTracks() to get the animation from the server on the server side. And it actually stopped on the server side but idk why it didnt replicated to the client side
All of my animation are played on the client side
Are there any problem about the replication or where can I fix this problem?