Hello! So I’m trying to make a teleport thing, pretty simple, but it won’t really work.
Every time I try to teleport, it says “TeleportToPrivateServer must be passed an array of players”
I looked at the official ROBLOX TeleportToPrivateServer topic thing and that didn’t work either, so this is my only option (the dev forum).
Notes:
The script is in a server script.
Everything else works except the teleport part.
Please help!
wait(3)
local parent = script.Parent
local teleportService = game:GetService("TeleportService")
local teleportID = 7682902943
local transitionEvent = game.ReplicatedStorage.TransitionEvent
local noKeyEvent = game.ReplicatedStorage.NoKeyEvent
local teleporting = false
local players = game:GetService("Players")
local playersToTeleport = players:GetPlayers()
local debounce = true
local cooldown = 1000
local function teleportPlayers()
local code = teleportService:ReserveServer(teleportID)
teleporting = true
teleportService:TeleportToPrivateServer(teleportID, code, playersToTeleport)
end
parent.Touched:Connect(function(hit)
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if hit.Parent:FindFirstChild("Humanoid") and debounce == true then
if hit.Parent:FindFirstChild("Key1") or player.Backpack:FindFirstChild("Key1") then
debounce = false
transitionEvent:FireAllClients()
wait(10)
teleportPlayers()
wait(cooldown)
debounce = true
else
noKeyEvent:FireAllClients()
end
end
end)