Making it check for players every 1 second

the part im talking about is line 10

local gameison = workspace.thegame.gameinprogress
local startgame = workspace.thegame.startgame


while true do
	wait(0.01)
	if startgame.Value == false then
		startgame.Value = true
		wait(10)
		local playerCount = #game.Players:GetPlayers()
		print("player checked there is " ..playerCount.. " players")
		if playerCount >= 1 then
			workspace.thegame.scripto.Disabled = false
			gameison.Value = true
			local playerCount = #game.Players:GetPlayers()

			local pllayer1 = workspace.thegame:FindFirstChild("player1").Value
			print(pllayer1)
			if pllayer1 ~= nil then
			
			workspace:FindFirstChild(pllayer1).HumanoidRootPart.Position = workspace.thegame.Plate1.PlayerSpawn1.Position + Vector3.new(0, 3, 0)
			game.Players:FindFirstChild(pllayer1).Team = game.Teams.living
		end
			local pllayer2 = workspace.thegame:FindFirstChild(workspace.thegame.player2.Value)
			if pllayer2 ~= nil then
				workspace:FindFirstChild(pllayer2).HumanoidRootPart.Position = workspace.thegame.Plate2.PlayerSpawn2.Position + Vector3.new(0, 3, 0)
				game.Players:FindFirstChild(pllayer2).Team = game.Teams.living
			end
			
			local pllayer3 = workspace.thegame:FindFirstChild(workspace.thegame.player3.Value)
			if pllayer3 ~= nil then
				print(pllayer1)
				workspace:FindFirstChild(pllayer3).HumanoidRootPart.Position = workspace.thegame.Plate3.PlayerSpawn3.Position + Vector3.new(0, 3, 0)
				game.Players:FindFirstChild(pllayer3).Team = game.Teams.living
			end

			local pllayer4 = workspace.thegame:FindFirstChild(workspace.thegame.player4.Value)
			if pllayer4 ~= nil then
				print(pllayer1)
				workspace:FindFirstChild(pllayer4).HumanoidRootPart.Position = workspace.thegame.Plate4.PlayerSpawn4.Position + Vector3.new(0, 3, 0)
				game.Players:FindFirstChild(pllayer4).Team = game.Teams.living
			end

			local pllayer5 = workspace.thegame:FindFirstChild(workspace.thegame.player5.Value)
			if pllayer5 ~= nil then
				print(pllayer5)
				workspace:FindFirstChild(pllayer5).HumanoidRootPart.Position = workspace.thegame.Plate5.PlayerSpawn5.Position + Vector3.new(0, 3, 0)
				game.Players:FindFirstChild(pllayer5).Team = game.Teams.living
			end


			local pllayer6 = workspace.thegame:FindFirstChild(workspace.thegame.player6.Value)
			if pllayer6 ~= nil then
				print(pllayer1)
				workspace:FindFirstChild(pllayer6).HumanoidRootPart.Position = workspace.thegame.Plate6.PlayerSpawn6.Position + Vector3.new(0, 3, 0)
				game.Players:FindFirstChild(pllayer6).Team = game.Teams.living	
			end
script.Disabled = true
			break
		end
	end
end
print("script ended")
1 Like

Could try something like this: (May need to edit to your liking)

local ManadatoryNumbers = {} --A table to hold all the numbers of the players who leave

local ValueStore = Instance.new('Folder')
ValueStore.Name = ValueStore
ValueStore.Parent = game.ServerStorage

game.Players.PlayerAdded:Connect(function(plr) --Checks for when a player joins the game
	plr.CharacterAdded:Connect(function(char) --Waits for their character to load
		local PlayerCount = #game.Players:GetPlayers()
		local Val = Instance.new('IntValue')
		local PlacementNumber
		if #ManadatoryNumbers > 0 then
			PlacementNumber =  PlayerCount
		else
			PlacementNumber = ManadatoryNumbers[1]
		end
		Val.Name = plr.Name
		Val.Value = PlacementNumber
		Val.Parent = ValueStore
		char:WaitForChild('HumanoidRootPart').CFrame = game.Workspace.thegame['Plate'..PlacementNumber]['PlayerSpawn'..PlacementNumber].CFrame * CFrame.new(0,1,0)
		plr.Team = game.Teams.Living
	end)
end)

game.Players.PlayerRemoving:Connect(function(plr)
	if ValueStore:FindFirstChild(plr.Name) then
		local Val = ValueStore:FindFirstChild(plr.Name) 
		table.insert(ManadatoryNumbers,Val.Value)
		game.Debris:AddItem(Val,0)
	end
end)

i was talking about just putting while true do above line 10… when i did it, it errored