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 3 years ago
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

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

1 answer

Log in to vote
1
Answered by 3 years ago

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

Ad

Answer this question