The game world mechanics I’m creating is that a player will usually be inside it’s own empty server when entered the game, until they switch worlds (joining to other player servers).
Just like the Roblox game: Islands, when you enter the game, you are in your own server until you join to other people’s server teleporting you in there.
Teleport the player to a Reserved Server using TeleportService methods:
if game:GetService("RunService"):IsStudio() then return end
if game.PrivateServerId ~= "" then return end -- ignore if this server is already private
local LoadingScreen = nil -- most likely want a loading screen here
local ts = game:GetService("TeleportService")
game.Players.PlayerAdded:Connect(function(player)
local accesscode = ts:ReserveServer(game.PlaceId)
ts:TeleportToPrivateServer(game.PlaceId, accesscode, {player}, nil, nil, LoadingScreen)
end)
I got a quick question about the teleport service:
Is it possible for a player to teleport in custom made-up place id? I am needing this so that if a player enters a server with a random id they typed, they’ll get teleported there.
This isn’t possible, but you can replicate this exact behavior by just using Datastores to save the access code, using this made-up id. I’m pretty sure access codes last forever and are never repeated.
I also apologize for the kind of confusion question about the ‘custom made-up placeid’. I just thought that place id means server id, but it’s actually the id of the game^^