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)
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)
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.
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!