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

How to make custom animations play even after death?

So when I use the wiki's tutorial for replacing default animations, it works just fine. However, upon death, it resets to default.

How would I fix this?

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=287905058'
end)

Game.Players.PlayerAdded:connect(function(player)
	while not player.Character do wait() end
	local character = player.Character
	local animateScript = character.Animate
	animateScript.fall.FallAnim.AnimationId = 'http://www.roblox.com/Assest?ID=287912301'
end)

Game.Players.PlayerAdded:connect(function(player)
	while not player.Character do wait() end
	local character = player.Character
	local animateScript = character.Animate
	animateScript.walk.WalkAnim.AnimationId = 'http://www.roblox.com/Asset?ID=287926677'
end)

Game.Players.PlayerAdded:connect(function(player)
	while not player.Character do wait() end
	local character = player.Character
	local animateScript = character.Animate
	animateScript.idle.Animation1.AnimationId = 'http://www.roblox.com/asset/?id=287939240'
end)

1 answer

✓ Accepted answer

Simple fix! Your problem is you are only firing this function only when a Player joined! not when they spawn! To fix this we need a CharacterAdded function!!

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(char)--Now this will fire when the character spawns!
    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=287905058'
	end)
end)

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(char)
    while not player.Character do wait() end
    local character = player.Character
    local animateScript = character.Animate
    animateScript.fall.FallAnim.AnimationId = 'http://www.roblox.com/Assest?ID=287912301'
	end)
end)	

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(char)
    while not player.Character do wait() end
    local character = player.Character
    local animateScript = character.Animate
    animateScript.walk.WalkAnim.AnimationId = 'http://www.roblox.com/Asset?ID=287926677'
	end)
end)

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(char)
    while not player.Character do wait() end
    local character = player.Character
    local animateScript = character.Animate
    animateScript.idle.Animation1.AnimationId = 'http://www.roblox.com/asset/?id=287939240'
	end)
end)


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