I want a group of players to be teleported to a subgame, but I don’t a different group to be teleported to the same server after that, (kinda like doors, where you cannot join someone elses game.) But it keeps giving this error. Also this is still in testing fazes so I don’t want it to be public to the world yet.
local TeleportService = game:GetService("TeleportService")
local teleportID = 14627040487
local textLabel = workspace.Sign.Text.SurfaceGui.Frame.TextLabel
local zone = script.Parent --// the part encasing the floor pad
local timer = 30
local PlayerTable = {}
while task.wait(1) do
PlayerTable = {}
timer -=1
print(timer)
textLabel.Text = ("Boat Departing in "..timer)
if timer == 0 then
timer = 0
local parts = workspace:GetPartsInPart(zone) --// get the parts inside of the zone
for _, part in parts do
local model = part:FindFirstAncestorOfClass("Model") --// check if the character model exists
if model and model:FindFirstChildOfClass("Humanoid") then --// check if the model has a humanoid
local player = PlayersService:GetPlayerFromCharacter(model) --// check if the character is a player
if player and table.find(PlayerTable, player) == nil then
table.insert(PlayerTable,player) --// add them to the table
end
end
end
if #PlayerTable > 0 then
TeleportService:TeleportAsync(teleportID, PlayerTable) --// teleport them
end
task.wait(1)
timer = 30 -- restart the cycle
end
end
game:BindToClose(function()
local PlayerTable = game:GetService('Players'):GetPlayers()
TeleportService:TeleportAsync(teleportID, PlayerTable)
end)