local TextButton = script.Parent
for i,v in pairs(TextButton:GetDescendants()) do
if v:IsA("TextButton") then
v.MouseButton1Down:Connect(function()
end)
end
end
This script closes every menu, I would like to close it (B001, G001, G002, G003, G004… Whichever one is open) as in the image above without using the frame name (local frame = script.Parent.G003 ), Thanks for answering!
local frame = script.Parent
local button = frame.Close
button.MouseButton1Click:Connect(function()
for i,v in pairs(frame:GetDescendants()) do
if v:IsA("Frame") and v.Visible == true then
v.Visible = false
end
end
end)
`Ë‹Ë‹
What do you mean by “is open”? Do you want to close all subframes (B001, G001…) when by clicking “X” button? If so you use this code:
local frame = script.Parent
local button = frame.Close
button.MouseButton1Click:Connect(function()
for _, child in pairs(frame:GetChildren()) do
if child:IsA('Frame') then
child.Visible = false
end
end
end)
I’m not sure what do you want to achieve so there is one more code that might work as you want:
local frame = script.Parent
local button = frame.Close
button.MouseButton1Click:Connect(function()
for _, descendant in pairs(frame:GetDescendants()) do
if descendant:IsA('GuiButton') and descendant.Name ~= 'Close' then
descendant.Parent.Visible = false
end
end
end)