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

Children of the frame?

Asked by
LostPast 253 Moderation Voter
9 years ago

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

2 answers

Log in to vote
1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

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
0
It will only work for TextButtons or ImageButtons Shawnyg 4330 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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)
0
Sorry if I didn't catch the question properly! TheDeadlyPanther 2460 — 9y

Answer this question