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

The problem of getting object names through a loop?

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

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).

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