Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What's wrong with my TeleportToReservedServer on click script?

Asked by 4 years ago
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?

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). killerbrenden 1537 — 4y
0
@killerbrenden player must be in a table, I have an answer myself exobyteXL 290 — 4y

2 answers

Log in to vote
1
Answered by
exobyteXL 290 Moderation Voter
4 years ago
Edited 4 years ago

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)

)

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. Trisodin529 89 — 4y
0
I'll edit the question so that you can see the multiplayer version - thanks for asking! exobyteXL 290 — 4y
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? Trisodin529 89 — 4y
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. Trisodin529 89 — 4y
View all comments (2 more)
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. Trisodin529 89 — 4y
0
Use a server script... exobyteXL 290 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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!

Answer this question