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

How can i make that when a player dies, it plays a random animation?

Asked by 4 years ago
Edited 4 years ago

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.

0
btw your english is pretty good actually speedyfox66 237 — 4y
0
Thank you ItsMatthew_RBX 0 — 4y
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 Godlydeathdragon 227 — 4y
0
Ok, thank you very much! ItsMatthew_RBX 0 — 4y

Answer this question