I have a round based system for a fighting game I am working on, but I am wondering how to end the round when there is one player left. I have a folder in the workspace called Ingame where players are stored while in the round. i also have a string value in Replicated Storage called Winner. which will store the name of the last player. How do I change the value of the string once there is one player left? Thanks.
✓ ANSWER ACCEPTED
How to end round when there is one player left?
1 answer
✓ Accepted answer
Hey!
If you're storing them all in a folder, you can use the ChildRemoved event on the folder to see when a player has left/been disqualified. After that, you can check how many instances are in the respective folder to see how many are left! An example of how this can be used is shown below...
folder.ChildRemoved:Connect (function()
if #folder:GetChildren() <= 1 then
print("1 or less players remaining!")
end
end)
If you didn't know already, folder:GetChildren() gathers a table with all of the instances in that folder and the # operator tells us how many indices are in that table. Using them together, we can determine how many instances are in the folder.
Hope this helped! If it did, please remember to mark as answered and upvote.
1 comment
1
Thanks man, saved my game.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Use the PlayerRemoving Event. game.Players.PlayerRemoving:Connect(function)