How do i fix this animation issue?

Im making a game and i decided to add a “Mounts” system, you simply press M and the character’s mount appears. But i started to have issues on the animations, they work fine for the player that activated the mount, but when an other player sees the player with the mount, the animations look like a mix of the old animations and the current ones. And even when the player deactivates his mount to get out of it, it still looks like a mix of the animations to the other player.

I even tried to make a new “Animate” script for it but it didn’t work. How can i fix this?

My code:

script.Parent.MountEvent.OnServerEvent:Connect(function(player,mount)
	local character = player.Character
	local hum = character:WaitForChild("Humanoid")
	local base = game.ReplicatedStorage.Mounts:FindFirstChild(mount)
	local anims = player.Character:WaitForChild("Animate")
	if script.Parent.Parent:FindFirstChild(mount) == nil then
		mountR = base:Clone()
		mountR.Parent = character
		mountR.Main6D.Part0 = character:FindFirstChild("HumanoidRootPart")
		anims.idle.Animation1.AnimationId = base.Stats.IdleAnim.AnimationId
		anims.idle.Animation2.AnimationId = base.Stats.IdleAnim.AnimationId
		anims.run.RunAnim.AnimationId = base.Stats.WalkAnim.AnimationId
		anims.walk.WalkAnim.AnimationId = base.Stats.WalkAnim.AnimationId
		anims.jump.JumpAnim.AnimationId = base.Stats.JumpAnim.AnimationId
		anims.fall.FallAnim.AnimationId = base.Stats.FallAnim.AnimationId
		hum.JumpPower = hum.JumpPower + base.Stats.JumpPower.Value
		hum.WalkSpeed = hum.WalkSpeed + base.Stats.WalkSpeed.Value
		mountR.Sound:Play()
	elseif script.Parent.Parent:FindFirstChild(mount) ~= nil then
		mountR.Main6D.Part0 = nil
		mountR:Destroy()
		anims.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=180435571"
		anims.idle.Animation2.AnimationId = "http://www.roblox.com/asset/?id=180435792"
		anims.run.RunAnim.AnimationId = "http://www.roblox.com/asset/?id=180426354"
		anims.walk.WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=180426354"
		anims.jump.JumpAnim.AnimationId = "http://www.roblox.com/asset/?id=125750702"
		anims.fall.FallAnim.AnimationId = "http://www.roblox.com/asset/?id=180436148"
		hum.JumpPower = hum.JumpPower - base.Stats.JumpPower.Value
		hum.WalkSpeed = hum.WalkSpeed - base.Stats.WalkSpeed.Value
	end
end)

Having replicated this similar issue in the past myself. The fix is normally the priorities of the animation themselves.

Not by code because it doesn’t replicate as we would assume
So instead of using AnimationTrack.Priority.

Are you setting the animation Priority from the animation plugin itself that you are using to something like “Action”?

i was using “Core”, but then i changed to “Action” to see if it would work, and it somewhat worked… but now when the player deactivates the mount, the mount animations still play (that issue only appears to the other player aswell)

Gotcha, pretty sure I can help you out with that.

Can I see the script where you play/stop the animations?
Also if the script is local or server?

I have some improvements for your script:

  • Send the Player’s Character from the Local Script
  • Get the priority of these default animations
  • Local Variables for Clones
  • Don’t use ‘~= nil’ or ‘== nil’, use instead ‘if not’ or ‘if’
  • Also what’s script.Parent.Parent?, Server Side Scripts can receive OnServerEvent (How did a script get there?)

The animations are those, the script changes the default player’s animations on the animate script, also the script is a server script

script.parent.parent is the player’s character, the script needs a remote event because the client script is the one that detects if the player pressed the M Key

Ah I see. So you are using the default Roblox Animate script defined at
local anims = player.Character:WaitForChild("Animate") with no changes to it?
^^ and this is a server script?

I understand the script in your original post is a server script and just making sure you know I was referring to the “Animate” script where your animations are played/stopped.

Then how’d the script get there?

yeah, it has no changes, and that server script is in a folder

StarterCharacterScripts, there is a folder with the mount system (the client script, a string value, the server script and a remote event)

Oh okay i thought it, take note of my improvements

1 Like

The animate script should normally be played Locally.

Also the mount animation played also in Animate? Or is it connected to a tool.activated event?

May I see where this mount animation is played?

its played in the animate script istelf, which is a client script

Can I see the code of the animate script?

its exactly the same as roblox’s default animate

I apologize, got a little confused at first but I understand now. So the reason for

It’s due to they haven’t been stopped & won’t be because of the remote event that changes the ID before they are stopped so they are no longer referenced and over-lapped by a whole new created track.

For better example; this is what I’m thinking.

anims.walk.WalkAnim.AnimationId = base.Stats.WalkAnim.AnimationId --/!!/  first animation
WalkAnim:Play() --/!!/  animation is playing
anims.walk.WalkAnim.AnimationId = "Another Animation" --/!!/  animation is changed before the last animation could be refrenced to stop.
WalkAnim:Stop() --/!!/  will NOT stop the 'WalkAnim:Play()'  2 lines above

--/!!/  the animation will keep playing because it is no longer able to be referenced correctly

Maybe what you could do in the Animate script is put where you deactivate you can put a stop() on those animations, then be changed.
Or
I see theres a stopAllAnimations function in the Animate script that might work correctly in your favor with alittle tweaking, and connect it to the deactivate / unequipped event.

thanks, i used the “stopAllAnimations()” function and it worked, apparently it just shutdowns every single animation in the script then restarts them. thanks a lot!