When a player types in to the textbox their class and the number decreases is what I have but how do I make it so if the person dies or disconnects the number goes back up?
For death:
Every character has a humanoid, and humanoids has a .Died event. To check every character that has joined the game, you also need to check every player that gets in the game since your script is server script.
Here's PlayerAdded event of game.Players
Here's CharacterAdded event of Player
And Here's Died event of Humanoid
And here's an example
game.Players.PlayerAdded:connect(function(Player) Lives = 3 Player.CharacterAdded:connect(function(Char) Char.Humanoid.Died:connect(function() Lives = Lives - 1 if Lives == 0 then print("Game Over") end end end end
For Leaving:
For this, we need to use game.Players' PlayerRemoving event.
And here's an example
game.Players.PlayerRemoving:connect(function(Player) print(Player.Name.." is leaving the server.") end
Additional note: Keep in mind that putting wait(Time)
after a PlayerRemoving event will cause an error if you try to work on that player since Server can't keep removed player's information that much.
Closed as Not Constructive by Goulstem
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?