Hello! I'm working on a game where when you touch an object you are teleported to a private server in a different place. I have recently discovered TeleportService and read about it on the Roblox developer site, but I still can't understand what some of it does. First of all, the explanation for "ReserveServer" was pretty vague, so I don't understand what that affects in the code. Also, does the place that is trying to be teleported to have to be in the same game? Here is my code:
function onTouched(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then if script.Parent.Active.Value == true then local TS = game:GetService("TeleportService") local code = TS:ReserveServer(game.PlaceId) -- Returns a code local Players = game:GetService("Players") local players = Players:GetPlayers() -- Get a list of all players TS:TeleportToPrivateServer(script.Parent.PlaceID.Value, code, players) end end end script.Parent.Touched:connect(onTouched)
Clarification: First the code did nothing, so I messed around with a few variables, that's why I'm using the "players" variable instead of "player".
Sorry if this is obvious, I am new to scripting.