Hey everyone,
I’m teleporting players for my story game, and my script isn’t working.
Here is my script:
coroutine.wrap(function()
while true do
wait()
for i = StartTime, 0, -1 do
if i == 0 and game.ReplicatedStorage.PlayersInBus.Value >= MinPlayers then
Teleporting = true
for _, Player in pairs(BusTable) do
game.ServerStorage.TeleportGui:Clone().Parent = Player.PlayerGui
Player.Character:Destroy()
Player.PlayerGui.ExitGui:Destroy()
end
local Code = TeleportService:ReserveServer(5191490565)
for _, Player in pairs(BusTable) do
local Remover = table.find(BusTable, Player)
table.remove(BusTable, Remover)
game.ReplicatedStorage.PlayersInBus.Value = #BusTable
end
TeleportService:TeleportToPrivateServer(5191490565, Code, BusTable)
Teleporting = false
elseif i == 0 and game.ReplicatedStorage.PlayersInBus.Value < MinPlayers then
game.ReplicatedStorage.Status.Value = MinPlayers.. ' players needed!'
wait(1)
elseif game.ReplicatedStorage.PlayersInBus.Value == 12 then
Teleporting = true
for _, Player in pairs(BusTable) do
game.ServerStorage.TeleportGui:Clone().Parent = Player.PlayerGui
Player.Character:Destroy()
Player.PlayerGui.ExitGui:Destroy()
end
local Code = TeleportService:ReserveServer(5191490565)
for _, Player in pairs(BusTable) do
local Remover = table.find(BusTable, Player)
table.remove(BusTable, Remover)
game.ReplicatedStorage.PlayersInBus.Value = #BusTable
end
TeleportService:TeleportToPrivateServer(5191490565, Code, BusTable)
Teleporting = false
end
game.ReplicatedStorage.Status.Value = 'The bus is leaving in '..i..' seconds'
wait(1)
end
end
end)()
The error I get is this:
Thanks for any help!