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

Is there a way to detect if player died?

Asked by
DesertusX 435 Moderation Voter
5 years ago
Edited 5 years ago

How could I know if a player died and use it in an if statement. In my game, every time a player dies, a point will be given to the other team. Is there a way to do this? Thank you for trying to help.

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago

You can use the .Died RBXScriptSignal of Humanoid to create an event upon the affiliated Player “dying”.

1local Player = game:GetService("Players").LocalPlayer
2local Character = Player.Character or Player.CharacterAdded:Wait()
3local Humanoid = Character:WaitForChild("Humanoid")
4 
5Humanoid.Died:Connect(function()
6    print(Player.Name.. " Died"
7end)
0
Thank you. :) DesertusX 435 — 5y
Ad

Answer this question