I Tried to do that, but i coudn't and idk what to do

Script:

local maps = game:GetService("ServerStorage").Maps:GetChildren()
local Title = game.StarterGui.MapSelector.Title
local spawns = game.Workspace.Spawns:GetChildren()
local status = game.ReplicatedStorage.Status
local LobbyCP = workspace.SpawnLocation

ti = 0

local playercount = 0
game.Players.PlayerAdded:Connect(function(plr)
	playercount += 1
end)

game.Players.PlayerRemoving:Connect(function(plr)
	playercount -= 1
end)

if playercount <= 2 then
	status.Value = "Waiting for More Players"
elseif playercount >= 2 or playercount == 2 then
	while true do
		ti = 30
		repeat
			ti = ti -1
			status.Value = "Intermission "..ti
			wait(1)
		until ti == 0

		local randomMap = maps[math.random(1, #maps)]
		randomMap:Clone().Parent = workspace
		current = randomMap.Name

		status.Value = "Chosen game is "..randomMap.Name
		wait(5)
		status.Value = "Loading game!"
		wait(2)
		status.Value = "Starting game!"
		LobbyCP.Parent = game.ServerStorage
		wait(2)

		local plrs = game.Players:GetChildren()

		for i = 1, #plrs do
			local randomSpawn = spawns[math.random(1, #spawns)]
			plrs[i].Character.HumanoidRootPart.CFrame = CFrame.new(randomSpawn.Position)
		end

		ti = 180
		repeat
			ti = ti -1
			status.Value = ti.." seconds left!"
			wait(1)
		until ti == 0

		workspace[current]:Destroy()
		wait(1)
		LobbyCP.Parent = workspace
	end
end

5 comments

0

what is the problem with the script?

0

Idk, the script is in the serverscriptservice and isn't a local script

0

is there an error?

0

no

0

I think you should place the if statements inside the loop