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.
The humanoid has its own function that runs when the player (humanoid) dies.
Checking if the humanoid died with a local script
1 | local player = game:GetService( "Players" ).LocalPlayer |
2 | local humanoid = player:WaitForChild( "Humanoid" ) |
3 |
4 | humanoid.Died:Connect( function () |
5 | --Do stuff |
6 | end ) |
Checking if the humanoid died with a script
01 | --This script is parented to ServerScriptService |
02 |
03 | game.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 ) |
12 | end ) |
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.
1 | game:GetService( 'Players' ).PlayerAdded:connect( function (Player) Player.CharacterAdded:connect( function (Character) |
2 | print ( 'Character has been respawned.' ) |
3 | Character.Humanoid.Died:connect( function () |
4 | print ( 'Character has been killed.' ) |
5 | end ) |
6 | end ) |
7 | end ) |