Hello Dev Forum, I came on here today to ask how I can make this Game Pass private server system below. (also kind of like grand piece online)
I have been trying to do research on it but I cant figure out how to do it.
Hello Dev Forum, I came on here today to ask how I can make this Game Pass private server system below. (also kind of like grand piece online)
I have been trying to do research on it but I cant figure out how to do it.
You can use TeleportService:ReserveServer. It returns the private server id that you can pass to TeleportService:TeleportToPrivateServer (or TeleportService:TeleportAsync)
ok so I have the Game Pass part done. I just need to know then how to make the generate code button work so when u press it, it gives u the random private server id
also what is the difference with teleport:async?
TeleportAync is just the newer method that combines every teleport method together in a single API call; they both do the same thing as TeleportToPrivateServer, the former is just more recommended
-- Example
local function generatePrivateServerCode() : string
-- returns a generated private server code to be used
return TeleportService:ReserveServer(game.PlaceId)
end
local function teleportToPrivateServer(players: {Player}, code: string)
-- this teleports the provided players to a private server
TeleportService:TeleportToPrivateServer(game.PlaceId, code, players)
end
-- Create a RemoteEvent to check if the player purchased a private server and teleport them to it
RemoteEvent.OnServerEvent:Connect(function(player: Player)
if PlayerPurchasedPrivateServer(player) then -- psuedo-code; basically, do something to check if the player bought a private server
local code = generatePrivateServerCode() -- this gets the generated code for the server
teleportToPrivateServer({player}, code) -- teleports the player who fired the remote
end
end)
This code is just an example on how you can handle teleporting players to the private server. To display the server code, you can create a RemoteEvent that sends the client the server code and have the client display it on their screen
ahh ok thank you so much i will try it out!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.