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

Single player teleportation on click script not working?

local TeleportService = game:GetService("TeleportService")
local Place = 4506512824
local RSID = TeleportService:ReserveServer(Place)
local players = game:GetService("Players")

script.Parent.MouseButton1Click:connect(function()
		game:GetService("TeleportService"):TeleportToPrivateServer(Place,RSID,{players})
end)

This script would be teleporting players with the click of a button, but there's apparently a problem with something. I went into a live game to test, and in the console it says: "TeleportService::TeleportToPrivateServer must be passed an array of players." I'm not sure what that is, or how I can fix it. This specific script is supposed to teleport just the one who clicked it, but right now it would teleport everyone. Can someone help me with this, or tell me what I'm doing wrong, and how to teleport just the one player? (btw thisis in a script, not a local)

1 comment

0

I think :TeleportToPrivateServer() is only used in scripts and not localscripts

1 answer

Problem

Single player teleportation on click script not working?

Solution

You can see the initial problem directly in the error and by reading your code.

local players = game:GetService("Players")

I went into a live game to test, and in the console it says: "TeleportService::TeleportToPrivateServer must be passed an array of players."

You're not passing an array of player objects, you're passing an array containing the player's service.

Try something like this, where you put all of the player instances in an array via getting all of the players in a table from the Players::GetPlayers method.

TeleportToPrivateServer(Place, RSID, players:GetPlayers())

P.S.

I suggest using a LocalScript and then using a RemoteEvent to inform the server that a player wants to reserve a server.

1 comment

0

No, that doesnt work either. The localscript thing isnt something I want to do, either.

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