Intermission System [BOUNTY]

Hello Developers,

Problem: After the cloned map got destroyed, and it does (correctfully) restart the round so it counts down from 10 to 0 but then 1. it does NOT choose the map again and 2. it keeps counting down from 10 in a loop without counting from 60 down or checking if winners >= players.

Any help is apprechiated. A fix will be rewarded with Robux.

while true do
	local playerCount = #Players:GetPlayers()

	while playerCount < 2 do
		local dotsCount = 0
		repeat
			Status.Value = "Waiting For Players" .. string.rep(".", dotsCount)
			wait(0.5)
			dotsCount = (dotsCount + 1) % 4
			playerCount = #Players:GetPlayers()
		until playerCount >= 2 or playerCount == 0
	end

	for i = 10, 1, -1 do
		Status.Value = "New Round Starting: " .. i
		wait(1)
	end

	if #Players:GetPlayers() < 2 then
		Status.Value = "Not enough players. Cancelling intermission."
		wait(3)
		continue
	end

	Status.Value = "Game Starting!"
	wait(1.5)

	local ChosenGame = Maps[math.random(1, #Maps)]
	local ClonedMap = ChosenGame:Clone()
	ClonedMap.Parent = game.Workspace

	for _, Player in pairs(Players:GetPlayers()) do
		local Character = Player.Character
		if Character then
			local humanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
			if humanoidRootPart then
				humanoidRootPart.CFrame = ClonedMap.TeleportBlock.CFrame

				ClonedMap.Start.StartPart.Touched:Connect(function(hit)
					wait(0.1)
					local character = hit.Parent
					local humanoid = character:FindFirstChildOfClass("Humanoid")

					local username = humanoid.Parent.Name

					if not soundPlayed[username] then
						table.insert(Participants, username)
						soundPlayed[username] = true

						if not Participants[username] then
							participatePlayer(username)
							print("Participated Player: "..username)
						end
					end
				end)
				ClonedMap.Finish.FinishPart.Touched:Connect(function(hit)
					wait(0.1)
					local character = hit.Parent
					local humanoid = character:FindFirstChildOfClass("Humanoid")

					local username = humanoid.Parent.Name

					if not finishSoundPlayed[username] then
						table.insert(Winners, username)
						finishSoundPlayed[username] = true

						if not Winners[username] then
							print("Win Player: "..username)
							winPlayer(username)
						end
					end
				end)
			end
		end
	end

	for count = 60, 0, -1 do
		Status.Value = tostring(count)

		if #Winners >= #Players:GetPlayers() then
			print("Ending countdown early.")
			break
		end

		wait(1)
	end

	ClonedMap:Destroy()

	currentPlace = 0
end
2 Likes

Are you getting any error messages in the output?

So apparently this is the culprit. It tells you the player count is MAXIMUM of 1. Any player count above 1, including 2, 3, 4 … n will result in restarting the intermission loop.

I mean yes, as long as there’s 2 or more players I want the round to keep restarting.

No. I’m not getting any errors.

That’s strange. Can you check the Maps while it is running? It looks like you have to check things on run-time I assume.

this video shows the problem

Ah, so it skips the entire chunk of code where you should have the map loaded and players teleported into. I noticed something in the video, and that is the players being teleported through humanoidRootPart.CFrame = ClonedMap.TeleportBlock.CFrame despite no whole map being there.

However, when the next map loads, all players incidentally cause #Winners >= #Players:GetPlayers() to be true. Ending the timer early and restarting the game intermission early. Maybe you have forgotten to clear out the #Winners when needed? It all happens lightning fast, so you will never notice the map loading and deleting at the same time.

:grin:

The problem was that I didn’t clear the Winners table! Thanks a lot, please send a gamepass of 100 Robux.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.