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

What exactly goes on behind the scenes when a player dies?

Asked by 4 years ago

I'm not fully understanding how a player specifically dies, even after doing lots of research.

1 answer

Log in to vote
1
Answered by 4 years ago
Edited by Ziffixture 4 years ago

When a character dies, the humanoid has a function run called BreakJoints()

An example of this is:

script.Parent.Touched:Connect(function(hit -- Block that hits it, in this case, a body part) -- Assuming if this Script was in a brick
    if hit.Parent.Humanoid then -- Checking if it's a character instead of a regular brick
        hit.Parent.Humanoid:TakeDamage(100) -- Kills the character, at this point is when the players humanoid runs the function BreakJoints()
    end
end)

When BreakJoints() is run, the Welds and Motor6Ds are destroyed. This causes the player to break apart into bricks.

To kill a player, you can either set the humanoid's Health to 0 or run the humanoid:TakeDamage() with the MaxHealth of the humanoid in the brackets.

EX:

humanoid:TakeDamage(100) -- If the MaxHealth of the humanoid is 100 this will kill it
-- or
humanoid.Health = 0 -- This will kill the humanoid in any case

Another rare way to do this, but not the suggested way, is to manually break the joints of the player using the humanoid:BreakJoints() function.

EX:

script.Parent.Touched:Connect(function(hit -- Block that hits it, in this case, a body part) -- Assuming if this Script was in a brick
    if hit.Parent.Humanoid then -- Checking if it's a character instead of a regular brick
        hit.Parent.Humanoid:BreakJoints() -- Kills the character by breaking the joints, causing it to not function at ALL. Doing this automatically makes the humanoid health go to 0, or kill the player
    end
end)

(the humanoid is what makes the player able to interact and move around its surroundings, or live. To see the roblox developer page for the humanoid click here )

1
(The character rig also refreshes. Meaning a new avatar gets loaded to the Player; complications may include prior declarations or allocations to the previous rig to be no longer valid. Ziffixture 6913 — 4y
0
what he said! NarwhalAndMe 141 — 4y
0
how exactly? ffancyaxax12 181 — 4y
0
because im trying to make a script that detects if a player dies and then resets their kill counter ffancyaxax12 181 — 4y
View all comments (4 more)
1
it clones the character, waits until the respawn time is over, then in the players character model it clones it back in. The player then controls the cloned version of themself. I saw your other comment, look into the humanoid page. That'll help you greatly with you because the humanoid controls all of the death. NarwhalAndMe 141 — 4y
0
thanks feahren for fixing it btw! NarwhalAndMe 141 — 4y
0
Ty Both ffancyaxax12 181 — 4y
0
No problem! Ziffixture 6913 — 4y
Ad

Answer this question