Need help using tables in a pairs loop

I’m trying to insert the names of all children under this folder into a table:

Here’s my issue, I’m not sure how to handle this.

I’m aware that I have to use a table when using in pairs(), but I have no idea how to handle this.

I also tried to count the number of children inside the “Allies” folder, but once again, that gives me an integer and not a table.

Here’s my code - note that Humans.Parent is replicated storage.

local rs = game.ReplicatedStorage
local allies = rs.Humans.Allies
local part1 = script.Parent
local allytypes = {}

for i,v in pairs(allies) do

local function GetTouchingParts(poggerspart)
	local connection = poggerspart.Touched:Connect(function() end)
	local results = poggerspart:GetTouchingParts()
	return results

while wait() do
	for j, v in pairs(GetTouchingParts(part1)) do
		if table.find(allytypes,tostring(v.Name)) then

Thanks so much to anyone who helps out :slight_smile:

allies is an instance, you can only use pairs on a table

v.Name is fine without tostring(), why convert a string into a string

allies is an instance, you can only use pairs on a table

Yeah, I have no idea how to convert the allies folder into a table though.

Also, fixed the tostring(), thanks for the help.

for i, v in pairs(allies:GetChildren()) do
    table.insert(allytypes, v.Name)

is this what you want?
it gets all the children with :GetChildren() and adds the names into allytypes

1 Like

Yup, that fixed it, thanks so much for the help!