TeleportToPrivateServer must be passed an array of players error

yippee me coming back here cuz of my trash code
trying to make thing where you can get a few people in a queue and then join a priv server

i keep getting this error even though there is more than one player?
heres a video to show:

(has to be a google drive links since video is too big to upload on devforum)

ive searched on devforum for similar problems but couldnt find a way to fix

2 Likes

Can you send the part of your script that includes the function?
also, ensure it is formatted somewhat like the following

:TeleportToPrivateServer(placeID, reservedAccessCode, {player1, player2})
1 Like

this is the script that teleports people (remotefunction is named weird lol)

local tps = game:GetService("TeleportService")


game.ReplicatedStorage.SetQuratue.OnServerEvent:Connect(function(plr, servernum)
	local players = game.Workspace.ServerQueues[servernum]:GetChildren()
	local privpvpserver = tps:ReserveServer(14850593104)
	tps:TeleportToPrivateServer(14850593104,privpvpserver,players)
	
end)

I may be wrong but I believe the players must be the Player Instance, not the Player’s Character.

1 Like

hmm yeah but i tried making a loop that does GetPlayerFromCharacter for each one but that gave out a different error cuz apparently theres supposed to be a table of players instead of just one

1 Like

What you could do, this is just a general idea you are gonna have to edit it

local PlayersToTeleport = {}
for i, v in pairs(game.Workspace.ServerQueues[servernum]:GetChildren()) do
	table.insert(PlayersToTeleport, game.Players:GetPlayerFromCharacter(v))
end

This will then give you a table of Player Instances which you can use to teleport them, I am assuming this would work since it insert’s each player instance in the table and then if you teleport them using the table its still formatted as a table.

3 Likes

k i did something pretty similar to this earlier but ill try and let you know how it goes

Okay cool, It would be something similar to this I believe:

local tps = game:GetService("TeleportService")


game.ReplicatedStorage.SetQuratue.OnServerEvent:Connect(function(plr, servernum)
	local PlayersToTeleport = {}
	
	for i, v in pairs(game.Workspace.ServerQueues[servernum]:GetChildren()) do
		table.insert(PlayersToTeleport, game.Players:GetPlayerFromCharacter(v))
	end	
	local privpvpserver = tps:ReserveServer(14850593104)
	
	tps:TeleportToPrivateServer(14850593104,privpvpserver,PlayersToTeleport)

end)
1 Like

this worked, tysm for the help

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.