So I have a ton of for loops in my game and whenever people leave they sometimes break. I know I could check if the thing I want to change is nil but I think I would have to do that a lot of times.
Here is ONE of my current for loops
for i, v in pairs(game.Players:GetChildren()) do v.PlayerGui.GameNotifications.Frame.TextLabel.Text = "It was... a tie! Nobody wins or gets any points!" end
The only way I can think of making that not get an error when someone leaves when it is running is by doing:
if winner == "None" then for i, v in pairs(game.Players:GetChildren()) do if v:FindFirstChild("PlayerGui") ~= nil then if v.PlayerGui:FindFirstChild("GameNotifications") ~= nil then if v.PlayerGui.GameNotifications:FindFirstChild("Frame") ~= nil then if v.PlayerGui.GameNotifications.Frame:FindFirstChild("TextLabel") ~= nil then v.PlayerGui.GameNotifications.Frame.TextLabel.Text = "It was... a tie! Nobody wins or gets any points!" end end end end end end
What is a better way error-proof this?