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

How do i make the players idle animation stay when a player dies?

I have an idle animation script in workspace that loads an animation when their idle. This is the script :

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

Any idea on whats going wrong? Or how to make that animation stay in the player when the player respawns

1 answer

✓ Accepted answer
game.Players.PlayerAdded:Connect(function(player) -- Use Connect with a capital
	player.CharacterAdded:Connect(function(Char)-- Connect their character spawning to an event
		repeat wait() until Char:FindFirstChild('Animate') ~= nil -- The event is fired when the body is spawned, and sometimes the animation script is not in yet.
    		Char.Animate.idle.Animation1.AnimationId = 'http://www.roblox.com/asset/?id=954273117' 
	end)
end)

Your script changes the player's idle animation when they join the game, not when they spawn. Simply connect it to the 'CharacterAdded' event. Also, just make sure to use 'Connect' instead of 'connect'! Have a good day.

2 comments

0

Thanks, for helping :)

0

Np

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