while true do game.Workspace.BackGroundMusic:Play() local text = game.ReplicatedStorage.TextValue local plrsleft = #game.Players:GetChildren() local pL = game.Players while true do local plrsleft = #game.Players:GetChildren() print("Not enough players...") text.Value = "Not enough players..." wait(1) if plrsleft >= 1 then wait(1) break end end while true do text.Value = "Intermission" print("Intermission") wait(15) text.Value = "Game is starting" print("Game starting") wait(5) local plrs = game.Players:GetChildren() for i = 1,#plrs do local num = math.random(1,8) plrs[i].Character.Head.CFrame = CFrame.new(workspace.Teleports["Part"..num].Position) end text.Value = "Welcome to Chances Of Doom..." wait(5) text.Value = "Let's begin." wait(5) text.Value = "A random player will be eliminated..." print("A random player will be eliminated...") wait(10) game.Workspace.LightBulb.Lightbulb.Light.Color = Color3.new(170, 0, 0) print(#plrs) if #plrs >= 1 then local eliminated = plrs[math.random(1,#plrs)] eliminated.Character.Humanoid.Health = 0 wait(3) text.Value = eliminated.Name.." has been eliminated." end game.Workspace.LightBulb.Lightbulb.Light.Color = Color3.new(255, 255, 255) wait(5) text.Value = "Anyways, let's move on..." wait(5) print("hi.....") while true do if #pL:GetChildren() <= 1 then print("Game restarting...") text.Value = "Restarting game..." wait(5) break end print("YEYEYEYY") wait(1) end end end
you can't have two while
loops running simultaneously. one loop should be enough to do the job.
EDIT: fixed player checking
local text = game:GetService('ReplicatedStorage'):WaitForChild('TextValue') local Players = game:GetService('Players') local PlayersLeft local IsPlayingFolder = Instance.new('Folder') IsPlayingFolder.Parent = game:GetService('ServerStorage') function DoubleCheck() local pl = #Players:GetChildren() if pl <= 1 then return true else return false end end workspace.BackGroundMusic:Play() while wait(1) do PlayersLeft = #Players:GetChildren() if PlayersLeft <= 1 then text.Value = "Not enough players..." print("Not enough players") elseif PlayersLeft > 1 then text.Value = "Intermission" print("Intermission") wait(15) if DoubleCheck(PlayersLeft) == true then text.Value = "Not enough players..." --double check if everyone's there return end text.Value = "Game is starting" print("Game is starting") wait(5) for i,v in pairs(Players:GetChildren()) do local newValue = Instance.new("BoolValue") --value type doesn't matter, just the name newValue.Name = v.Name newValue.Parent = IsPlayingFolder end local plrplaying = IsPlayingFolder:GetChildren() for i,v in pairs(plrplaying) do local num = math.random(1,8) local plr = Players:FindFirstChild(v.Name) if plr and plr.Character and plr.Character:FindFirstChild("Head") then plr.Character.Head.CFrame = CFrame.new(workspace.Teleports["Part"..num].Position) end end text.Value = "Welcome to Chances of Doom..." wait(5) text.Value = "Let's begin." wait(5) text.Value = "A random player will be eliminated..." print("a rando will be elim") wait(10) workspace.Lightbulb.Lightbulb.Light.Color = Color3.new(170,0,0) PlayersLeft = Players:GetChildren() print("Players left: "..#PlayersLeft) if #PlayersLeft > 1 then local eliminated = PlayersLeft[math.random(1,#PlayersLeft)] if eliminated.Character and eliminated.Character:FindFirstChild('Humanoid') then eliminated.Character.Humanoid.Health = 0 end if IsPlayingFolder:FindFirstChild(eliminated.Name) then IsPlayingFolder[eliminated.Name]:Destroy() --removes their in game presence after killing end wait(3) text.Value = eliminated.Name.." has been eliminated." wait(5) elseif #PlayersLeft == 1 then print('Only one person in-game!') return end workspace.LightBulb.Lightbulb.Light.Color = Color3.new(255, 255, 255) wait(5) text.Value = "Anyway, let's move on..." wait(5) local PlayersLeftPlaying = IsPlayingFolder:GetChildren() if #PlayersLeftPlaying == 1 then text.Value = PlayersLeftPlaying[1].Name.." is the last man standing! Restarting..." wait(5) for i,v in pairs(IsPlayingFolder:GetChildren()) do v:Destroy() --make sure no values are left end return end --moving on? end end