Here, I have a script:
t = 0
while true do
local rooms = game.ReplicatedStorage:WaitForChild("GeneratedObs"):GetChildren()
local s = script.Stat
local plrs = game.Players:GetChildren()
local vals = game.ReplicatedStorage.vals
local ingame = workspace.Ingame:GetChildren()
if #plrs > 1 then
t = 15
repeat
t = t-1
s.Value = "Intermission... "..t
wait(1)
until t == 0
s.Value = "Game starting!"
wait(5)
for i, placeHolder in pairs(game.Workspace.PlaceHolders:GetChildren()) do
local chosenRoom = rooms[math.random(1,#rooms)]:Clone()
chosenRoom.PrimaryPart = chosenRoom.Floor
chosenRoom:SetPrimaryPartCFrame(placeHolder.CFrame)
placeHolder.Transparency = 1
chosenRoom.Parent = game.Workspace
end
for i = 1,#plrs do
local num = math.random(1,8)
plrs[i].Character.Head.CFrame = CFrame.new(workspace.Teleports["Part"..num].Position)
plrs[i].Character.Parent = workspace.Ingame
plrs[i].Character.Humanoid.Health = plrs[i].Character.Humanoid.MaxHealth
end
t = 180
repeat
t = t - 1
s.Value = t.." seconds left!"
wait(1)
until t == 0 or vals.Winner.Value ~= "" or #ingame < 2
else
s.Value = "Two or more players are needed to play."
wait(1)
end
end
This script is for a game where obstacles are randomly selected from ReplicatedStorage and placed over a "placeholder" block with CFraming. The players are initially held in a lobby until the obstacles have loaded, and are then teleported to the beginning of the course.
During Solo testing, everything works fine where there is only one player in the game, therefore most of the script is not actually executed. However in a Local Server, as soon as the two players are teleported to the beginning of the course, one second passes on the timer and suddenly the game reverts to the "Intermission" stage almost as if it is ignoring until t == 0 or vals.Winner.Value ~= "" or #ingame < 2. I've tried double checking that the winners value wasn't already filled, and I've also tried looking for any typos with the folders used for the script. I'm not quite sure what's causing this to happen, and any help would be much appreciated!

2 comments
have you tried print(#ingame) . maybe the table is set before player 2 enters the game
I have tried printing #ingame, it returns 0 until the second round which then returns 2 as it should have done.