TeleportToPrivateServer must be passed an array of players

I want to teleport the players that are in my Table. I was trying to insert the player from a stringvalue to
the table. But when I try to teleport its showing me an error in the Console
I have tried many different ways to make it work but it didn’t.

game.ReplicatedStorage.Teleport.OnServerEvent:Connect(function(player)

local Member = {}
print(player.Name)
local children = game.ReplicatedStorage:FindFirstChild(player.Name…"'s GroupRequests").StringValues:GetChildren()
for i = 1, #children do
table.insert(Member,children[i])
end
print(unpack(Member))
TeleportService:TeleportToPrivateServer(
Place,
TeleportService:ReserveServer(Place),
Member)
end)

StringValues are stored in the ReplicatedStorage

Explorer

you should do something like:

local players = {}

for _, player in next, game.ReplicatedStorage["Anton00k's GroupRequests"].StringValues:GetChildren() do
if not table.find(players, player.Name) then
      table.insert(players, player.Name)
end
end

note:

in that folder should be Any Values with players name

Try this in the for loop:

local player = game.Players:FindFirstChild(children[i].Value) -- or. Name
if player then
   table.insert(Member, player) 
end

EDIT: Corrected the code

2 Likes

thanks for corecting me, so this will be the script:


for _, player in next, game.ReplicatedStorage["Anton00k's GroupRequests"].StringValues:GetChildren() do
if not table.find(players, player.Name) then
      table.insert(players, player.Value, tonumber(_))
end
end

it should be a StringValue

hope i helped u!

I made another edit to my code, so you can see how to correctly make it. Also, it’s not necessary to specify table.insert’s third argument because by default, it puts the value in the next index of the table, which would be #Table + 1

yeah, but if the player changes his name it will break

Have you watched my video that I uploaded to the post? If a player changes his name he has to rejoin.

yes, in it don’t show u need to rejoin if u change ur name