I’m not sure what went wrong in this script. It teleports the player, but in a private server, it’ll teleport the player to a public place instead of a private one.
This script is currently in a local script within a GUI. What it’s supposed to do, is teleport a player after they click on a button, and make a teleporting gui visible. Everything works, except for the private server aspect. It continues to teleport you into a public server from a private server.
local button = script.Parent
local player = game:GetService("Players").LocalPlayer
local TeleportService = game:GetService("TeleportService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PlaceId = 6010776300
function OnActivation()
print("hi")
TeleportService:SetTeleportGui(ReplicatedStorage:FindFirstChild("TeleportGUI"))
local random = math.random(1,4)
local Frame = player.PlayerGui.TeleportGUI.Frame
Frame.Active = true
if random == 1 then
Frame.Clownfish.Visible = true
print("worls")
end
if random == 2 then
Frame.Global.Visible = true
end
if random == 3 then
Frame.ChalkGirl.Visible = true
end
if random == 4 then
Frame.FakeCoaches.Visible = true
end
--//Teleport That Player
if game.PrivateServerId ~= "" then
if game.PrivateServerOwnerId ~= 0 then
local reservedServer = TeleportService:ReserveServer(PlaceId)
print("sup")
TeleportService:TeleportToPrivateServer(PlaceId,reservedServer,{player})
end
else
TeleportService:Teleport(PlaceId,player)
TeleportService:GetLocalPlayerTeleportData()
print("Teleporting")
end
end
button.Activated:Connect(OnActivation)