Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
oSyM8V3N 429 Moderation Voter
6 years ago

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

Log in to vote
0
Answered by 6 years ago
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.

0
Thanks, for helping :) oSyM8V3N 429 — 6y
0
Np iamnoamesa 674 — 6y
Ad

Answer this question