Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

?My script which includes "GetChildren()" Gives out only 1 object from it

for i,Buttons in pairs(Gui:GetChildren()) do
	for i,v in pairs(Buttons) do
		v.MouseButton1Click:connect(function()
			print(v)
		end)
	end
end

 --bad argument #1 (table expected, got Object)

My Gui has 2 objects, shirt and pants but for some reason it gives out only "Shirt" so it doesn't creates table and gives out that error. Don't know what causes this problem

1 comment

0

if someone wonders, no "wait()" won't fix this problem, I tried

1 answer

✓ Accepted answer

Are you sure you need the second for i, v.

for i,Button in pairs(Gui:GetChildren()) do
Button.MouseButton1Click:Connect(function()
print(Button.Name)
end)
end
 

This discussion is preserved as it was. New answers, comments, and votes are closed.