You first have to reserve the server, doing
:ReserveServer(placeId)
and then you have to teleport them to the reserved server, doing
TeleportToPrivateServer(placeId, reserveServer Code, player)
You CANNOT teleport in ROBLOX Studio, only in Live ROBLOX Servers.
Wiki
local TS = game:GetService("TeleportService")
local placeId = 4506512824
local serverCode = TS:ReserveServer(placeId)
local players = {player}
TS:TeleportToPrivateServer(placeId,serverCode,players)
You first have to set the code you received from the reserve server function, and use that to teleport the player.
Then you have to create a table, as that's the argument that is passed through teleport to private server.
Then you use the teleport to private server function, and the first argument is the place id you want them to teleport to, the second one is the server code you received from reserve server function, and then the table of players that you want to teleport.
I'm not sure on how you have your GUI's and stuff setup, but this is how it's supposed to be used.
You can adjust this to fit your needs.
Hope this helped! Didn't have much time to go into detail, but if this helped you, don't forget to select this as the answer!
3 comments
You first have to reserve the server, doing :ReserveServer(placeId), and then you have to teleport them to the reserved server, doing TeleportToPrivateServer(placeId, reserveServer Code, player).
https://developer.roblox.com/en-us/api-reference/class/TeleportService
@killerbrenden player must be in a table, I have an answer myself