when i try to teleport it says it’s a restricted place but i do provide the access code with i thought would mean it would let me in. i guess i’m not sure how access codes work so any help would be much appreciated thank you
local event = game.ReplicatedStorage.Teleport.room
local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")
event.OnServerEvent:Connect(function(player,CODE) -- code is sent from the client and is the reserved server's access code
TS:TeleportToPrivateServer(9999999999,CODE,{player}) -- not the real place id but that's where the place id would go
end)
is the place you’re teleporting to in the same game? if not, is it the starting place of the game it’s in?
you can’t teleport to a non-starting place of another game
local event = game.ReplicatedStorage.Teleport.room
script.Parent.button.MouseButton1Click:Connect(function()
event:FireServer(script.Parent.code.Value) -- there is a int value with the code
end)
local code = TS:ReserveServer(999999999) -- 999.. isn't the real place id but this line of code makes a reserved server for the place id there
for i,v in ipairs(game.Players:GetChildren()) do -- when someone teleports to their reserved server it will also add it to a list in a gui for everyone still in the lobby so others can join, that other script was for joining a reserved server from this list
local gui = v.PlayerGui.popUps.map.rooms.otherRoom.ScrollingFrame.room:Clone() -- makes a gui that will be used as a button to teleport
gui.Visible = true
gui.Parent = v.PlayerGui.popUps.map.rooms.otherRoom.ScrollingFrame
gui.displayName.Text = player.DisplayName
gui.userName.Text = ("@")..player.Name
gui.code.Value = code
end