Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago
1for i,Buttons in pairs(Gui:GetChildren()) do
2    for i,v in pairs(Buttons) do
3        v.MouseButton1Click:connect(function()
4            print(v)
5        end)
6    end
7end
8 
9 --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

0
if someone wonders, no "wait()" won't fix this problem, I tried SuAkihiro 94 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

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

1for i,Button in pairs(Gui:GetChildren()) do
2Button.MouseButton1Click:Connect(function()
3print(Button.Name)
4end)
5end
Ad

Answer this question