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.
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.