Array list issue

  1. I want the script to send by remote event an array list of the players that have a frame in the scrolling frame

  2. The issue is that when i print the table it prints a empty table

Note that every frame in the groupscrollingframe is the name of the player This array list is also send to the server so the players in it can be teleported with TeleportAsync()

Frame.StartButton.MouseButton1Click:Connect(function()
				if Frame.GroupScrollingFrame:FindFirstChildOfClass("Frame") then
					
					local Players = {}
					
					for i, frame in pairs(Frame.GroupScrollingFrame:GetChildren()) do
						if frame:IsA("Frame") then
							for i, player in pairs(game.Players:GetPlayers()) do
								if player.Name == frame.Name then
									table.insert(Players, game.Players:GetPlayers()[player])
								end
							end
						end
					end
					
					table.insert(Players, localPlayer.Name)
					
					print(Players)
					
					RS.TeleportPlayer:FireServer(Players)
					
				end
			end)

Pls help

1 Like

Players:GetPlayers() returns a table which is an array of all the Players currently in the server.
It returns a table indexed with numbers, not other Instance references.

For example a table recieved with Players:GetPlayers() may go as:

{
    [1] = Player1,
    [2] = Player2,
    [3] = Player3,
}

Try doing table.insert(Players, player) instead.
Since you already know which player instance it is.

It seems to work when printing, now I’ll try in game so i can see if it teleports them or not

1 Like

Now when i print it on the client it all good but when i print it on the server it only prints 1 of the 2 players i want to teleport

Can you make sure all the players are correctly labeled in the GroupScrollingFrame instance?

It is well labeled using a script to clone a template and name it to the player’s name

I just tryied on roblox and it only teleport the player that invited

Yes I’ve also noticed that you are storing the LocalPlayer as a name below here too did you want to store names or just instances in this table?

I just want to store instance to use them for a teleportAsync() method but i also changed it to table.insert(Players, localPlayer)

are you absolutely sure these frames are of the class “Frame”?

try printing print(Frame.GroupScrollingFrame:GetChildren()) maybe player frames going in that scrollingframe is just bugged?

 {
                    [1] = UIListLayout,
                    [2] = UIPadding,
                    [3] = UIStroke,
                    [4] = UIAspectRatioConstraint,
                    [5] = Player1
                 }

This is what i’m getting, all the things for the ui and the frame Player1

Wait now i changed the findfirstchildofclass(“Frame”) to :IsA("Frame) and it doesn’t print the table anymore

Okay so firstly I don’t think you should be allowing the server to select players to teleport to a different place. Exploiters could abuse this.

Secondly I can’t replicate the issue you are having :confused: its probably somewhere with how instances are looped through and/or their ClassNames.