Hello fellow developers ! I want to make a player list similar to that of arsenal where the picture of 8 players will be visible on every players screen and I want that as soon as a person dies , a cross appears on their screen. I have designed the gui but not sure about the code. I will really appreciate any help I receive.
use PlayerService to check if the player.Character.Humanoid has died then run a code.
Example:
game:GetService('Players').PlayerAdded:Connect(function(player) -- When new player joins
player.CharacterAdded:Connect(function(character) -- Wait for player character
character:WaitForChild("Humanoid").Died:Connect(function() -- Check if humanoid died
print(player.Name .. " has died!")
end)
end)
end)
though, you have to do this on a serverscript inside ServerScriptStorage, the script should run before any players joined the server yet meaning if theres already players in the server and you runned this script, those player wont get detected when they die.
Alternatively:
You can use loops to check all the players at once and when their health is below zero.
1 Like