Cant teleport player to reserved server

  1. What do you want to achieve? Keep it simple and clear!
    i want to teleport a player to a place in the experience
  2. What is the issue? Include screenshots / videos if possible!
    im recieving the error Argument 2 missing or nil on line 22
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    nothing i have tried has worked
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
    the script is a server script btw
-- local ts = game:GetService("TeleportService")
local placeid = placeid
local plr1
local plr2
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player, player1, player2)
	plr1 = tostring(player1)
	
end)
local reservedserver

local s, e = pcall(function()
	reservedserver = ts:ReserveServer(placeid)
end)

script.Parent.MouseButton1Up:Connect(function()
	local users
	users = {	
		game.Players[plr1],
		
	} 		

	ts:TeleportToPrivateServer(placeid, reservedserver, users)
	
	end)

1 Like

You need to reference the player directly, or you could use player1.Name

Player reference:

local placeid = placeid
local plr1
local plr2
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player, player1, player2)
	plr1 = player1
end)

local reservedserver

local s, e = pcall(function()
	reservedserver = ts:ReserveServer(placeid)
end)

script.Parent.MouseButton1Up:Connect(function()
	local users
	users = {	
		plr1,
		
	} 		

	ts:TeleportToPrivateServer(placeid, reservedserver, users)
	
	end)

Player name:

local placeid = placeid
local plr1
local plr2
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player, player1, player2)
	plr1 = player1.Name
	
end)

local reservedserver

local s, e = pcall(function()
	reservedserver = ts:ReserveServer(placeid)
end)

script.Parent.MouseButton1Up:Connect(function()
	local users
	users = {	
		game.Players[plr1],
		
	} 		
	ts:TeleportToPrivateServer(placeid, reservedserver, users)
	
	end)

im still having an issue where it now says i cant cast a value to object on line 22