How to join a already reserved server

I know how I can use the reserved server script but I want to telport 1 player to there (I also know how to do this) but then I made something where the player in the reserved server can invite other players, from this I can get the job instance of the reserved server but everytime I want to teleport the player to the reserved server I get the error that the place is restricted, how can I solve this
btw I used teleport to place instance with the jobId

I get something like unable to cast value to object

After reserving, it requires you to utilize the GlobalDataStore for it. Once generating the reservation code, make sure you store it in the GlobalDataStore and make sure it is removed upon shutdown.

https://developer.roblox.com/en-us/api-reference/function/TeleportService/TeleportToPrivateServer
If you have troubles with errors from the function, please read the arguments required.

In conclusion, make sure you save the ID of the reserved server then use the function based on what ID was selected.

1 Like
local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")   
local players = Players:GetPlayers()

 local code = DS:GetAsync("ReservedServer")
if type(code) ~= "string" then -- None saved, create one
	code = TS:ReserveServer(game.PlaceId)
	DS:SetAsync("ReservedServer",code)
end

TS:TeleportToPrivateServer(game.PlaceId,code,players)

Should this be the right way to do it?

Not quite. You are missing the fact that this restricts reserved servers count to only 1. Perhaps you could employ a method to actually create multiple ones with different identifiers?

Oh really you can only make 1 max? I tried it with 2 accounts to create a reserved server and both of the accounts were in a different server…

I actually meant joining, not creating. You will only save one and the only first server to be reserved.

I quite dont get it but I just wanted to try something simple out that turned in something verry difficult :weary: