Basically, I'm trying to make a code that starts the game once the server finds that there are 2 or more people playing (It will say if they are playing via ModuleScript, not if they are in the game)
The way how I'm attempting to do this is by:
Finding the number of players in the server (every 2 seconds)
If there are 2 or more players, the server will go through each player's descendants using forloop
The server finds the ModuleScript(GameSettings) inside a player's PlayerScripts and it's variable(Playing)
if GameSettings.Playing = "yes", the variable "PlayingValue" will increase by 1.
the script goes through other players and when the PlayingValue is 2 the game will begin
local Game = require(game.ReplicatedStorage.Game) --Gets the variables from the Game module script(Only Variable is GameStatus)
local GameSettings = require(game.StarterPlayer.StarterPlayerScripts.GameSettings)----Gets the variables from the GameSettings module script(Only Variable is playing)
local PlayingValue = 0
while true do
local Players = game.Players:GetChildren()--finds how many things are in players
local PlayerNumber = #Players --Get's the number of Players
if PlayerNumber >=2 then
for ActivePlayers = 0,PlayerNumber do
if Players[ActivePlayers].PlayerScripts.GameSettings.Playing == "yes" then
print("People are playing")
PlayingValue = PlayingValue + 1
else
print("People are not playing.")
end
end
if PlayingValue >=2 then
if Game.GameStatus == "unstarted" then
Game.GameStatus = "starting"
end
end
else
print("The game will start when there are 2 players playing or more!")
end
wait(2)
end
The problem is that the code is unable to go through the player's descendants. So, basically the problem is in this codeline:
if Players[ActivePlayers].PlayerScripts.GameSettings.Playing == "yes" then
Any help would be greatly appreciated. Thank You!

1 comment
what is the exact error? being unable to go through the descendants can mean a couple things