Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What's wrong with my TeleportToReservedServer on click script?

local TeleportService = game:GetService("TeleportService")

local Place = 4506512824

local player = game.Players.LocalPlayer

 

script.Parent.MouseButton1Click:connect(function()

    TeleportService:Teleport(Place, player)

end)

That's my script. It's supposed to teleport the player to the dungeon alone as a "quickstart" feature. It doesnt do anything on click, and there are no errors. Is there anything I'm doing wrong?

3 comments

0

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).

0

@killerbrenden player must be in a table, I have an answer myself

2 answers

✓ Accepted answer

You used Teleport, not TeleportToPrivateServer. First, you need to reserve a server. You can do this by using the code:

local RSID = game:GetService("TeleportService"):ReserveServer(game.PlaceId)

NOTE: You cannot create reserved servers in Roblox Studio. You must be in a live game.

Visit the Roblox Developer Wiki for more info on ReserveServer

This will create a new ReservedServer. The RSID variable will be the ReservedServer ID.

To teleport people to a ReservedServer, use:

game:GetService("TeleportService"):TeleportToPrivateServer(game.PlaceID,RSID,{player})

Visit the Roblox Developer Wiki for more info on TeleportToPrivateServer

Argument 1: Game Place ID Argument 2: Reserved Server ID Argument 3: Table of players that you want to teleport

Hope this helps!

(The fixed version of your code:

local TeleportService = game:GetService("TeleportService")

local Place = 4506512824

local RSID = TeleportService:ReserveServer(Place)



script.Parent.MouseButton1Click:connect(function()

  game:GetService("TeleportService"):TeleportToPrivateServer(Place,RSID,{player})

end)

Multiplayer version:

local TeleportService = game:GetService("TeleportService")

local Place = 4506512824

local RSID = TeleportService:ReserveServer(Place)



script.Parent.MouseButton1Click:connect(function()
  local players = {}
  local children = game.Players:GetChildren()
  for i = 1, #children do
  	if children[i].ValueLocation.Value == true then
	table.insert(players,children[i])
  end
  end

  game:GetService("TeleportService"):TeleportToPrivateServer(Place,RSID,players)

end)

)

6 comments

0

How would I make all the players with a boolean inside of them all tp to the same reserved server? I ask this, because theres also a multiplayer thing, which creates a bool inside of each player when someone makes a lobby, then when they join it ticks it to true, when its started, all players with it ticked to true get teleported.

0

I'll edit the question so that you can see the multiplayer version - thanks for asking!

0

And by "Player needs to be a table", do you mean I need to set that, or is that script up there fine to work?

0

Yeah, didn't work. There's an error at the player table thing. There's nothing saying what the player is. I'm not sure how to fix that.

0

I couldn't get it to work, but get the reputation anyways. It says something about reserved servers only being able to be called by the server client or something.

0

Use a server script...

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.