Need help with getting children of two instances in same line

local perks = script.Parent:WaitForChild("Frame"):WaitForChild("Perks"):WaitForChild("uistuf")


for i,v in pairs(crates:GetChildren(), perks:GetChildren()) do
	if v:IsA("TextButton") then
		v.MouseEnter:Connect(function()
			print(v, "Hovered")
			v.Text = v:WaitForChild("Price").Value -- Changes the text to the price of that item.
		end)
		v.MouseLeave:Connect(function()
			print(v, "Leaving")
			v.Text = v.Name -- Changes text back to the orginal.	
		end)
	end

end```

It only gets the children of crates not perks.

formatting error, I do define crates

you can’t really do that, you have to seperate them.

aw really? It looks much cleaner like this

2 Likes

if the perks,crate has the Parent then
well you can use GetDescendants() to check for every Descendant.

local objects = {}
local function f(_, v) table.insert(objects, v) end
table.foreach(crates:GetChildren(), f)
table.foreach(perks:GetChildren(), f)

for i, v in pairs(objects) do
	print(i, v)
end

table.foreachi could also be used, table.move too although the implementation would be slightly different.

oh that is a good way, I will use that --------------