Hello everyone! I am a making a round based game and I insert the contestants that are ready to play the game into a table called contestants. Then I want to check if there in enough players to play the game. Here’s part of the script. If you can please help it would be greatly appreciated!
Error occurs when I make the local numberofcontestants
On Line 22, you accidentally called GetChildren on a table. You can only call GetChildren on an Instance which returns a table, but you already have a table so there’s no need to use GetChildren. Do this instead:
The script won’t work because contestants is a static table once the first iteration is complete. You can solve this in many ways. Perhaps the most simple one is to nest the for loop inside the repeat loop. This way, your script will handle almost at real time when a player abandons the menu.
Also, I think you should add a function to delete players from the contestants table when they leave the game (using table.remove). Ignore this if you’re sure this doesn’t apply
Create a variable to make sure the round has started or not, so you can do this:
local isRound = false
local ingamePlayers = {}
while wait(2) do
if not isRound then
for i,v in pairs(game.Players:GetPlayers()) do
if not v:FindFirstChild("InMenu") then
table.insert(ingamePlayers, v)
end
end
if #ingamePlayers >= contestantsToStart then
--Code to run when in game players are over the requirements
end
end
end
(Didn’t see your last post but well I will let this in case this helps.)