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
7 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 7 years ago
Edited 7 years ago

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

Checking if the humanoid died with a local script

local player = game:GetService("Players").LocalPlayer
local humanoid = player:WaitForChild("Humanoid")

humanoid.Died:Connect(function()
    --Do stuff
end)

Checking if the humanoid died with a script

--This script is parented to ServerScriptService

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        local humanoid = character:WaitForChild("Humanoid")
        if humanoid then
            humanoid.Died:Connect(function()
                --Do stuff
            end)
        end
    end)
end)
Ad
Log in to vote
0
Answered by 7 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 7 years ago
 game:GetService('Players').PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character) 
print('Character has been respawned.') 
Character.Humanoid.Died:connect(function() 
print('Character has been killed.') 
end) 
end) 
end)
0
Your code isn't indented which makes it hard for anyone to read UltimateRaheem 75 — 7y

Answer this question