So this my current script which if a player leaves in round it will remove them from the player inrounds folder. This should work but for some reason doesn’t and the game teleport just breaks which breaks the entire game.
Players in the InRounds folder are string values which are stored as the players name.
So what I want to happen is when the player leaves then it will get rid of them from the inround folder.
Right now in the if statement you are comparing “player.Name” (a string) to an instance “game.Workspace.MainFrame.InRound:WaitForChild(player.Name)”. This will always return false. Instead, compare player.Name to the name of the UIElement inside of “InRound”, or it’s text. Something that is a string that should be the name of the player.
This is because you put parenthesis around player.Name, which is used for calling a function. Instead use :FindFirstChild or brackets “[]” surrounding the string
I think IsKid has the solution. But this is what I would do for the script. A bit different from yours but it should work better I believe.
local players = game:GetService("Players")
players.PlayerRemoving:Connect(function(player)
local playerString = workspace.MainFrame.InRound:FindFirstChild(player.Name)
if playerString then
playerString:Destroy()
print("Destroyed")
else
print("No StringValue named "..player.Name)
end
end)