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

The problem of getting object names through a loop?

Asked by 7 years ago

What is the problem? I need to get the names of all the ImageButton, but instead I get "nil". Where was I wrong?

script.Parent.MouseButton1Click:connect(function()

    local logos = script.Parent.Parent:GetChildren()
    for i,v in pairs(logos) do
        if v:IsA("ImageButton") then
            print(logos.Name)
        end
    end

end)

1 answer

Log in to vote
3
Answered by
duckwit 1404 Moderation Voter
7 years ago

You're trying to print the name of the table logos instead of the name of each ImageButton in the table.

Change line 6 from print(logos.Name) to print(v.Name).

Ad

Answer this question