How to reserve a server for one person

I tried to reserve a server on my game by clicking on a gui button, just see it as to create a party

local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")
 
local code = TS:ReserveServer(game.PlaceId) -- Returns a code
local players = Players:GetPlayers() -- Get a list of all players
 
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function()
TS:TeleportToPrivateServer(game.PlaceId,code,players)
end)

I used the code that is provided on the roblox developer page but it always give me this error

I also tried to change my code and add this

local players = {}
for _,v in pairs(Players) dothis for loop
table.insert(players,v)
end

But it still doesnt work…

Get players when event is fired (put player variable inside that function) as this server script loads before player and doesn’t get any players in the array.

1 Like

oh yeah thx man, this was so easy that I didnt see it lol