Help with rounds system

So I am trying to make a rounds system that has an intermission where all players are sent to the lobby and a round when all players are sent to the map except those that join after the round started. I have two scripts, one to handle the rounds and one to handle player joining

RoundHandler

local players = game.Players
local active = true
local RS = game:GetService("ReplicatedStorage")
local roundTime = RS:WaitForChild("RoundTime")
-- Time
local intermissionTime = 10
local gameTime = 15

while active do
	for i = intermissionTime, 1,-1 do
		roundTime.Value = "Intermission ends in "..i.." seconds"
		wait(1)
	end
	RS.RoundActive.Value = true
	for i = gameTime, 1,-1 do
		roundTime.Value = "Round ends in "..i.." seconds"
		wait(1)
	end
	RS.RoundActive.Value = false
end

PlayerAdded Script

local players = game.Players
local RS = game:GetService("ReplicatedStorage")
local lobby = game.Workspace.Lobby



players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Wait()
	if RS:WaitForChild("RoundActive").Value == true then
		plr.Character:SetPrimaryPartCFrame(lobby.CFrame + Vector3.new(0, 2, 0))
	elseif RS:WaitForChild("RoundActive").Value == false then
		plr.Character:SetPrimaryPartCFrame(lobby.CFrame + Vector3.new(0, 2, 0))
	end
end)

so… What do you need help with?

Oh yeah. The system doesnt seem to work and it doesnt throw any errors so I am not sure what is wrong

in the while loop, you just put While active do. You need to put:

while active == true do

Whenever you have a problem with any code that seems to not give errors, you should put prints randomly throughout the script to help you minimize where the problem could be occurring. Try this and see where the problem is.

1 Like

you are not using for i, v in pairs correctly
the proper way to use it in this situation would be

for i = 1, intermissionTime do
      wait(1)
end
1 Like

Wouldn’t the intermissionTime part be for i = 1, #intermissionTime do wait(1) end

plr.CharacterAdded:Wait()
I don’t think you can do this. I think its suppose to be plr.Character:Wait()
(I could be wrong so please correct me if I am :slight_smile: )

intermissionTime is already a number, so i don’t think it would be needed to put a #.

@KeeganwBLK it is plr.CharacterAdded:Wait()
CharacterAdded

I fixed your problem.