Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this animation script stop after I die?

game.Players.PlayerAdded:connect(function(player)
	while not player.Character do wait() end
	local character = player.Character
	local animateScript = character.Animate
	animateScript.jump.JumpAnim.AnimationId = 'http://www.roblox.com/asset/?id=340097749'
	end)

This Anim script stops playing after I die. How do I fix the issue?

2 comments

0

So are you trying to make a death animation? As to if the player dies an animation plays everytime a player dies?

0

No, a jump animation. For example, I made a jump animation, all the time I'm alive, it plays every time I jump. But when I die or respawn, when I jump, it just goes back to the original jump animation. Not the one I made.

1 answer

✓ Accepted answer

http://wiki.roblox.com/index.php?title=API:Class/Player/CharacterAdded

Try using the CharacterAdded event in conjunction with PlayerAdded. This way, the animation is replaced every time the player spawns instead of just once when the player enters the game.

I would also recommend storing the animation as its own variable, to make future changes easier.

local JUMP_ANIM_NEW = 'http://www.roblox.com/asset/?id=340097749'

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        local animateScript = character:WaitForChild("Animate")
        local jump = animateScript:WaitForChild("jump")
        local JumpAnim = jump:WaitForChild("JumpAnim")
        JumpAnim.AnimationId = JUMP_ANIM_NEW
    end)
end)

1 comment

0

Thanks for the wiki link and script m8!

This discussion is preserved as it was. New answers, comments, and votes are closed.