local TeleportService = game:GetService("TeleportService")
local RP = game:GetService("ReplicatedStorage")
local Players = [Link]
local mainGameID = 18825338143 -- CHANGE TO UR GAME'S ID
local queueFolder = [Link]:WaitForChild("Queue")
local joinedEvent = [Link]:WaitForChild("JoinedQueue")
local leftEvent = [Link]:WaitForChild("LeftQueue")
local playerLimit = 4
local countDownTime = 10
for _, queueRoom in ipairs(queueFolder:GetChildren()) do
local enterHitBox = [Link]
local exithitBox = [Link]
local tpEnterPos = [Link]
local tpExitPos = [Link]
local playersInQueueFolder = [Link]
local UIBillboard = [Link]:WaitForChild("ui").BillboardGui
local playersUI = [Link]
[Link] = #playersInQueueFolder:GetChildren() .. "/" .. playerLimit
local timerUI = [Link]
[Link] = countDownTime .. " Seconds"
local countdownCoroutine
[Link]:Connect(function(other)
local db = false
if not (#playersInQueueFolder:GetChildren() >= playerLimit) and not db
and [Link]:FindFirstChild("Humanoid") then
db = true
[Link] = [Link]
if not playersInQueueFolder:FindFirstChild([Link])
then
local newPlayer = [Link]("StringValue",
playersInQueueFolder)
[Link] = [Link]
[Link] = [Link]
end
if countdownCoroutine ~= nil and
[Link](countdownCoroutine) == "dead" then
countdownCoroutine = nil
end
if countdownCoroutine == nil then
countdownCoroutine = [Link](function()
CountDownTeleport(playersInQueueFolder, UIBillboard) end)
[Link](countdownCoroutine)
end
[Link] = #playersInQueueFolder:GetChildren() .. "/" ..
playerLimit
--lock the player's camera to tpExitPos
local player = Players:GetPlayerFromCharacter([Link])
joinedEvent:FireClient(player, tpExitPos)
[Link](.1)
db = false
end
end)
[Link]:Connect(function(other)
local db = false
if not db and [Link]:FindFirstChild("Humanoid") then
db = true
[Link] = [Link]
if playersInQueueFolder:FindFirstChild([Link]) then
playersInQueueFolder:FindFirstChild([Link]):Destroy()
end
if #playersInQueueFolder:GetChildren() == 0 and
countdownCoroutine ~= nil then
[Link](countdownCoroutine)
countdownCoroutine = nil
[Link] = countDownTime .. " Seconds"
end
[Link] = #playersInQueueFolder:GetChildren() .. "/" ..
playerLimit
local player = Players:GetPlayerFromCharacter([Link])
leftEvent:FireClient(player)
[Link](.1)
db = false
end
end)
end
function CountDownTeleport(folder, Billboard)
for i = countDownTime, 1, -1 do
print("Countdown: " .. i)
[Link] = i .. " Seconds"
[Link](1)
end
[Link] = "Teleporting..."
local party = {}
for _, player in pairs(folder:GetChildren()) do
[Link](party, Players:FindFirstChild([Link]))
end
local reservedServer = TeleportService:ReserveServer(mainGameID)
TeleportService:TeleportToPrivateServer(mainGameID, reservedServer, party)
for _, player in pairs(folder:GetChildren()) do
player:Destroy()
end
[Link] = countDownTime .. " Seconds"
[Link] = "0/"..playerLimit
end