Hello there. Currently, I am trying to make a system where a player joins the game, they have a bool value in their player, and when they press a button in the main menu GUI, the bool value goes away ( Don't worry I already have the bool value system that goes away when they press a GUI ) and they are added into a table in a script. But the problem is that when I want it to print something when a player joins the table, it doesn't print anything.
local contestants = {}
for _, v in pairs (game.Players:GetPlayers()) do
if not v:FindFirstChild("CanPlay") then
table.insert(contestants, v)
print("A player has been added to the contestants")
end
end
Any answers are accepted. Thank you for your time. Stay safe. ShortTeamROBLOX

4 comments
Use .PlayerAdded
But thing is that if I use the playeradded event, then the function would only run when the player joins the game, lets say the player is afk in the main menu and they get teleported to the map, I don't want that to happen.
Let me just try .PlayerAdded to see if it works
The thing is that if I do PlayerAdded, it will look for when I join the game and it will stop afterwards. et me post the script I used.