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

Children of the frame?

how do check if an of the children of a frame in a gui is clicked.

2 answers

Well, you would use a generic loop. Example:

for i,v in pairs(script.Parent.Frame:GetChildren()) do
	v.MouseButton1Down:connect(function()
		print(v.Name.." was clicked")
	end)
end

1 comment

0

It will only work for TextButtons or ImageButtons

Please make your question more understandable. You cannot click frames, you need a TextButton/ImageButton.

local button = script.Parent.Button

button.MouseButton1Down:connect(function()
	-- Your code here.
end)

If you want to find one of the frame's children:

local button = script.Parent.Button
local frame = script.Parent.Parent

button.MouseButton1Down:connect(function()
	-- frame:GetChildren()
	-- or
	-- frame:FindFirstChild("NameHere")
end)

1 comment

0

Sorry if I didn't catch the question properly!

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