How to amke a death animation script code example

Example: How to amke a death animation script

-- Made by JUB0T or Rigby#9052 on Discord
local deathAnimation = Instance.new("Animation")
local deathAnimationLoop = Instance.new("Animation")
local Dead = {
	Dead1 = "rbxassetid://4510222745",
}
local DeadLoop = {
	DeadLoop1 = "rbxassetid://4506398261",
}

game:GetService("Players").PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		humanoid.BreakJointsOnDeath = false
		character.Archivable = true
		humanoid.Died:connect(function()
			local PossibleAnims = {Dead.Dead1}
			local Anim = PossibleAnims[math.random(1, #PossibleAnims)]
			deathAnimation.AnimationId = Anim
			character.HumanoidRootPart.Parent = nil		
			character.Humanoid.DisplayDistanceType = "None"
			local animTrack = character.Humanoid:LoadAnimation(deathAnimation)
			animTrack:Play()
			wait(animTrack.Length)
			local PossibleAnimLoops = {DeadLoop.DeadLoop1}
			local AnimLoop = PossibleAnimLoops[math.random(1, #PossibleAnimLoops)]
			deathAnimationLoop.AnimationId = AnimLoop
			local animTrackLoop = character.Humanoid:LoadAnimation(deathAnimationLoop)
			animTrackLoop:Play()
		end)
	end)
end)

Tags:

Misc Example