Teleport a single player to a reserved server

  1. What do you want to achieve? Keep it simple and clear!
    A: I want to teleport only a SINGLE player to a reserved server!
  2. What is the issue? Include screenshots / videos if possible!
    I need to send an array of players!
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I did look for solutions but didn’t find any that helped.

Script code:
script.Parent.Parent.Parent is the player i want to send
the 0123456789 is just for deco reasons

local TS = game:GetService("TeleportService")

local code = TS:ReserveServer(5935268124)

local playerrr = {
	script.Parent.Parent.Parent
}

script.Parent.Yes.MouseButton1Up:Connect(function()
	wait(0.25)
	TS:TeleportToPrivateServer(5935268124,code,playerrr)
end)

Before asking for help on the forum make sure you check any errors logged in the output window to see if they can help you solve the issue yourself. If you still need help, please include those errors here so we can help you understand them and debug your code more efficiently.

While I’m guessing 0123456789 is not the actual ID of the place you’re using. Please include the real place ID as certain settings may affect whether or not it can be teleported to.

I suspect from your code that this is a LocalScript. LocalScript’s cannot reserve a private server or teleport a player to one. You need to use a Script running on the server to do that and will need to use a remote to communicate between that and your LocalScript.

However, do you even need a private server for this? It looks like you want single player servers which you could just achieve by setting the player limit to one on some place and teleporting player’s to them.

There is only one error that says I need an array of players and I want to make a tutorial and for this I need a seperate server, real id get’s edited in yet and this is a script not a localscript, I make sure that it is no dumb fault from my side and the Idea with limit to one player method sounds interesting.

It is like a tower defense game but you have to fight the enemy’s actively and the towers are only secondary damage dealer so you can’t win a game only with towers.

Use a remote event and call the teleport from server-side. I have a similar script and it works with a single player. I do not have something like mouse button click related, in my script players just have to stand on a block and they get teleported.

I would create a RemoteEvent in ReplicatedStorage and use these scripts

local script

script.Parent.Yes.MouseButton1Up:Connect(function()
	wait(0.25)
    game.ReplicatedStorage.RemoteEvent:FireServer()
end)

put a script in ServerScriptService

local TS = game:GetService("TeleportService")

local code = TS:ReserveServer(5935268124)

game.ReplicatedStorage.OnClientEvent:Connect(function(player)
    local Playerrrr = {}
    table.insert(Playerrrr, player)
    TS:TeleportToPrivateServer(5935268124,code,playerrr)
end)

try something similar to this I guess

1 Like

You are missing an array of players.
Instead of doing:

TS:TeleportToPrivateServer(5935268124,code,playerrr)

You need to change it to:

TS:TeleportToPrivateServer(5935268124,code,{playerrr})
1 Like

its already an array. its says on roblox website the thing can be only called server-side, he is using local script I think.

I already said at the reply for woot3 im using a normal serversided script lol

LocalScript:

script.Parent.Yes.MouseButton1Up:Connect(function()
	wait(0.25)
    game.ReplicatedStorage.RemoteEvent:FireServer()
end)

Script:

local TS = game:GetService("TeleportService")

local code = TS:ReserveServer(5935268124)

game.ReplicatedStorage.OnClientEvent:Connect(function(player)
    local Playerrrr = {}
    table.insert(Playerrrr, player)
    TS:TeleportToPrivateServer(5935268124,code,playerrr)
end)

worked but hoped for a serversided solution… you know… exploiter can abuse remotes

maybe do something like

local FireEvent

FireEvent = script.Parent.Yes.MouseButton1Up:Connect(function()
	wait(0.25)
    game.ReplicatedStorage.RemoteEvent:FireServer()
    FireEvent:Disconnect()
end)

I guess this should stop them from spamming.

I found a solution. I made a check if the player was new to the game it is helpful for the gui either cause if the player isn’t new then the tutorial doesn’t show up

1 Like