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

How can you make a script tell if a user has died or been respawned?

Asked by
Scrixt -5
8 years ago

Im making a hotel room board and it will check if the user has left or has been respawned and idk how to check for that.

3 answers

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

The humanoid has its own function that runs when the player (humanoid) dies.

Checking if the humanoid died with a local script

1local player = game:GetService("Players").LocalPlayer
2local humanoid = player:WaitForChild("Humanoid")
3 
4humanoid.Died:Connect(function()
5    --Do stuff
6end)

Checking if the humanoid died with a script

01--This script is parented to ServerScriptService
02 
03game.Players.PlayerAdded:Connect(function(player)
04    player.CharacterAdded:Connect(function(character)
05        local humanoid = character:WaitForChild("Humanoid")
06        if humanoid then
07            humanoid.Died:Connect(function()
08                --Do stuff
09            end)
10        end
11    end)
12end)
Ad
Log in to vote
0
Answered by 8 years ago

Define all the players in a local script. Then do a DiedFunction, then make a Frame visible. Thats pretty much it Not going to give script.

Log in to vote
0
Answered by 8 years ago
1game:GetService('Players').PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character)
2print('Character has been respawned.')
3Character.Humanoid.Died:connect(function()
4print('Character has been killed.')
5end)
6end)
7end)
0
Your code isn't indented which makes it hard for anyone to read UltimateRaheem 75 — 8y

Answer this question