Tf is up with my round system

  1. What do you want to achieve? my round system to work

  2. What is the issue? idk its just broken lol here’s the video 2022-12-08 09-10-15

local Players = game:GetService("Players")
local Teams = game:GetService("Teams")

LobbyTeam = Teams:WaitForChild("Lobby")
RoundTeam = Teams:WaitForChild("Round")

RoundInProgress = false
AreaSpawns = workspace:WaitForChild("GreenAreaSpawns")

function LobbyToRound()
	warn("Init - LobbyToRound")
	for _, PlayerInLobby in ipairs(LobbyTeam:GetPlayers()) do
		local Character = PlayerInLobby.Character or PlayerInLobby.CharacterAdded:Wait()
		local Humanoid = Character:WaitForChild("Humanoid")
		local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
		local RandomSpawnPos = AreaSpawns:GetChildren()[math.random(1, #AreaSpawns:GetChildren())].Position
		local SkillScript = Character:WaitForChild("SkillReplicator")
		Humanoid.MaxHealth = 100
		Humanoid.Health = 100
		SkillScript.Enabled = true
		HumanoidRootPart.CFrame = CFrame.new(RandomSpawnPos)
		PlayerInLobby.Team = RoundTeam
	end

	task.spawn(function()
		for x = 300, 0, -1 do 												-- Round duration
			wait(1)
			print("Waiting until round ends...")
			local PlayersInRound = RoundTeam:GetPlayers()
			
			task.spawn(function()
				for _, player in ipairs(PlayersInRound) do
					local Character = player.Character or player.CharacterAdded:Wait()
					local Humanoid = Character:WaitForChild("Humanoid")
					Humanoid.Died:Connect(function()
						player.Team = LobbyTeam
					end)
				end
			end)
			
			if #PlayersInRound ~= 0 then
				if #PlayersInRound == 1 then
					local Winner = RoundTeam:GetPlayers()[1]
					task.spawn(function()
						for _, player in ipairs(Players:GetPlayers()) do
							player.PlayerGui:WaitForChild("Top Text").Contents.Label.Text = "Champion: "..Winner.Name
						end
					end)
					RoundInProgress = false
					RoundToLobby() 														-- END ROUND
				else
					for _, player in ipairs(Players:GetPlayers()) do
						player.PlayerGui:WaitForChild("Top Text").Contents.Label.Text = "Round in progress: "..x
					end
					if x <= 0 then
						for _, player in ipairs(Players:GetPlayers()) do
							player.PlayerGui:WaitForChild("Top Text").Contents.Label.Text = "Game over! No winners :c"
						end
						RoundInProgress = false
						RoundToLobby()
					end
				end
			end
		end
	end)

end

function RoundToLobby()
	warn("Init - RoundToLobby")
	task.wait(5)
	for _, PlayerInRound in ipairs(RoundTeam:GetPlayers()) do
		local Character = PlayerInRound.Character or PlayerInRound.CharacterAdded:Wait()
		local Humanoid = Character:WaitForChild("Humanoid")
		local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
		local CafeSpawn = workspace:WaitForChild("Map").TeleportPart
		local SkillScript = Character:WaitForChild("SkillReplicator")
		SkillScript.Enabled = false
		HumanoidRootPart.CFrame = CFrame.new(CafeSpawn.Position)
		Humanoid.MaxHealth = math.huge
		Humanoid.Health = Humanoid.MaxHealth
		
		PlayerInRound.Team = LobbyTeam
	end
	RoundStartCountdown()
end

function RoundStartCountdown()
	warn("Init - RoundStartCountdown")
	for x = 60, 0, -1 do -- Wait duration in seconds until the round starts
		wait(1)
		AmountOfPlayersInLobby = #LobbyTeam:GetPlayers()
		Requirement = 1
		if RoundInProgress == false then
			for _, player in ipairs(Players:GetPlayers()) do
				player.PlayerGui:WaitForChild("Top Text").Contents.Label.Text = "Time until round start: "..x
			end
		end
	end
	if AmountOfPlayersInLobby >= Requirement then
		RoundInProgress = true
		LobbyToRound()																-- START ROUND
	end
end

RoundStartCountdown()

Ya i see the issue, it could be as if what others would say, “the script tend to break of its code”.

But tbh, I’m not really sure why as to it glitches for a quick moment that showed a 100’s digit number before showing the count number. As the from 67 to 66 for instance.

Or, it could be a runtime error, double check your code and hopefully it helps…

For starters this code is bot ver efficient. You will be hooking up Died events 300 times if so one lives the whole match.