How to play a animation when you die?
✓ ANSWER ACCEPTED
How to play a animation when you die? Please Awnser.
1 answer
✓ Accepted answer
I suggest using this script. That you should put in ServerScriptService.
--//Instructions\-- Step1.) Put the script in ServerScriptSerivce.
Step2.) Make a folder and put it into ReplicatedStorage, and name the Folder "Animations".
Step3.) Put the Animation into the Folder, and name the animation whatever you want.
Step4.) Find "local deathAnimation = " then locate "("Change this to the animation Name")", and change it to the Animations name.
--//Script\--
--[[
When a player dies, creates a clone of their character and plays a death animation of your choosing
Place in ServerScriptService
--]]
-- Replace with your animation
local deathAnimation = game.ReplicatedStorage:WaitForChild("Animations"):WaitForChild("Change this to the animation Name")
local animationLength = 0 ---Animation length
function onCharacterAdded(player)
local character = player.Character
character.Humanoid.Died:Connect(function() --detects when a player dies.
character.Archivable = true
local dummyCharacter = character:Clone()
character.Archivable = false
character.Parent = nil
for _,obj in pairs(dummyCharacter:GetChildren()) do
if obj:IsA("Script") or obj:IsA("LocalScript") then
obj:Destroy()
end
end
dummyCharacter.Parent = workspace
dummyCharacter.Archivable = false
dummyCharacter.Humanoid:LoadAnimation(deathAnimation):Play() --animation is played.
wait(animationLength) --The animationLength
dummyCharacter:Destroy()
end)
end
function onPlayerAdded(player)
if player.Character then
onCharacterAdded(player)
end
player.CharacterAdded:Connect(function()
onCharacterAdded(player)
end)
end
for _,player in pairs(game.Players:GetPlayers()) do
onPlayerAdded(player)
end
game:GetService("Players").PlayerAdded:Connect(onPlayerAdded)
I suggest this, but I have not used it in a while.
This discussion is preserved as it was. New answers, comments, and votes are closed.

10 comments
Vincentthecat it doens't work.
Did you change the "game.ReplicatedStorage:WaitForChild("Animations"):WaitForChild("Name")"? Because You need to change "Name" to your animations name, and you need to make a Folder in replicatedStorge Called Animations, and have to put the animation in to.
Then for the "local deathAnimation = " Make it "local deathAnimation = game.ReplicatedStorage:WaitForChild("Animations"):WaitForChild("Change this to the animation Name")".
I find this too hard but i have another script is this one good?
-- Put in StarterCharacterScripts in StarterPlayer wait() local Humanoid = script.Parent.Humanoid Humanoid.BreakJointsOnDeath = false local DA = Instance.new("Animation") DA.AnimationId = "rbxassetid://2510197257" local DeathAnimation = Humanoid:LoadAnimation(DA) Humanoid.HealthChanged:Connect(function(Health) if Health <= 0 then print("Died") script.Parent.HumanoidRootPart.Anchored
The reason it was so hard to understand was because I did not make it clear in the answer. I'll edit it to make it more easy to understand.
I tried to make it clear. Just contact me on discord if you have any trouble. My discord is "VincenttheBaguette1#1253".
It doesn't work :(
Ok i try to add you as friend on discord
friend me on discord