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

How to make custom animations play even after death?

Asked by 8 years ago

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

Log in to vote
0
Answered by 8 years ago

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)


Ad

Answer this question