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