The While loop isn't working on line 45 - 54. It doesn't run and there are no error messages. This is the script: (Sorry for the fact that it is not indented properly, i pasted in into here and it did that.)
local CollectionService = game:GetService("CollectionService")
local tag = "Teleporter"
for _, object in pairs(CollectionService:GetTagged(tag)) do
spawn(function()
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Model = object.Parent
local Script = script
local OutsideSpawnPoint = Model:WaitForChild("OutsideSpawnPoint")
local InsideSpawnPoint = Model:WaitForChild("InsideSpawnPoint")
local Counter = Model:WaitForChild("Counter")
local Configuration = Model:WaitForChild("Configuration")
local Moniter = Model:WaitForChild("Moniter")
local GlobalAddPlayer = ReplicatedStorage:WaitForChild("AddPlayer")
local GlobalRemovePlayer = ReplicatedStorage:WaitForChild("RemovePlayer")
local GlobalPlayerAdded = ReplicatedStorage:WaitForChild("PlayerAdded")
local GlobalPlayerRemoved = ReplicatedStorage:WaitForChild("PlayerRemoved")
local mapcollection = {5131207726,5133272479,5135288464}
local WaitingPlayers = {}
local CanJoin = true
local CountingDown = false
local currentmapid = mapcollection[math.random(1,#mapcollection)]
Configuration.Mapnumber.Value = currentmapid
print(currentmapid)
function teleportPlayers()
local PlaceID = currentmapid
local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")
local code = TS:ReserveServer(PlaceID)
local players = {}
for _, v in pairs(WaitingPlayers) do
table.insert(players, Players:WaitForChild(v))
end
TS:TeleportToPrivateServer(PlaceID, code, players)
WaitingPlayers = {}
end
if CountingDown == false then
while false do
wait(1)
if CountingDown == false then
currentmapid = mapcollection[math.random(1,#mapcollection)]
print(currentmapid)
break
end
end
end
function startCountDown()
if not CountingDown then
local CanSend = true
CountingDown = true
for i = 30, 0, -1 do
Counter:WaitForChild("BillboardGui"):WaitForChild("TextLabel").Text = " ".. i.. " "
if #WaitingPlayers <= 0 then
CanSend = false
end
break
end
wait(1)
if CanSend then
CanJoin = false
wait(1)
Counter:WaitForChild("BillboardGui"):WaitForChild("TextLabel").Text = "Teleporting..."
teleportPlayers()
wait(5)
currentmapid = mapcollection[math.random(1,#mapcollection)]
print(currentmapid)
Counter:WaitForChild("BillboardGui"):WaitForChild("TextLabel").Text = "Waiting For Players..."
CanJoin = true
else
Counter:WaitForChild("BillboardGui"):WaitForChild("TextLabel").Text = "Waiting For Players..."
end
CountingDown = false
end
end
function removePlayer(Player)
for num, item in pairs(WaitingPlayers) do
if item == Player.Name then
table.remove(WaitingPlayers, num)
GlobalPlayerRemoved:FireClient(Player)
if Workspace:FindFirstChild(Player.Name) then
if Workspace[Player.Name]:FindFirstChild("Humanoid") and Workspace[Player.Name]:FindFirstChild("HumanoidRootPart") then
Workspace[Player.Name].HumanoidRootPart.CFrame = OutsideSpawnPoint.CFrame
end
end
break
end
end
end
function addPlayer(Player)
if CanJoin == true then
local Passed = false
if #WaitingPlayers <= 0 then
Passed = true
else
for _, item in pairs(WaitingPlayers) do
if item == Player.Name then
Passed = false
break
else
Passed = true
end
end
end
if Passed then
table.insert(WaitingPlayers, Player.Name)
GlobalPlayerAdded:FireClient(Player)
if Workspace:FindFirstChild(Player.Name) then
if Workspace[Player.Name]:FindFirstChild("Humanoid") and Workspace[Player.Name]:FindFirstChild("HumanoidRootPart") then
Workspace[Player.Name].HumanoidRootPart.CFrame = InsideSpawnPoint.CFrame
end
end
end
end
end
function findNearByPlayer()
for _, v in pairs(Workspace:GetChildren()) do
if v.Parent and v:FindFirstChild("Humanoid") and v:FindFirstChild("HumanoidRootPart") then
if (Counter.Position - v.HumanoidRootPart.Position).magnitude < Configuration:WaitForChild("Distance").Value then
if Players:FindFirstChild(v.Name) then
addPlayer(Players:WaitForChild(v.Name))
end
end
end
end
end
GlobalAddPlayer.OnServerEvent:Connect(function(Player)
addPlayer(Player)
end)
GlobalRemovePlayer.OnServerEvent:Connect(function(Player)
removePlayer(Player)
end)
spawn(function()
while wait() do
findNearByPlayer()
if #WaitingPlayers >= 1 then
startCountDown()
end
end
end)
end)
end
If you need any other information, please ask!

2 comments
ok i will see if that works
Thanks, it worked. I just had to change that and remove the 'break' and it worked