Hello everyone, I need help scripting a code that makes a player play a random animation when it dies. I have a code from a YouTube tutorial from Hyperr Hydra. This is my code

wait()
local Humanoid = script.Parent.Humanoid
Humanoid.BreakJointsOnDeath = false
local DA = Instance.new("Animation")
DA.AnimationId = "rbxassetid://myid"
local DeathAnimation = Humanoid:LoadAnimation(DA)

Humanoid.HealthChanged:Connect(function(Health)
	if Health <= 0 then
		script.Parent.HumanoidRootPart.Anchored = true
		DeathAnimation:Play()
		wait(3.5)
		script.Parent:Destroy()
	end
end)

I want that the player play one animation of various, for example. I would be very grateful if you could help me, thanks. And sorry if I have a bad translation, I don't speak English.

4 comments

0

btw your english is pretty good actually

0

Thank you

0

Use math.random to choose what animation to play. Also, instead of checking if the Humanoid's health is less than 0, use the Humanoid.Died event

0

Ok, thank you very much!