script.Parent.MouseButton1Down:Connect(function()
for i,v in pairs(game:GetChildren(script.Parent.Parent.Parent) do
print(v)
if v.Name ~= “Selection” or “Dragify” or “UICorner” then
v.Visible = false
end
end
script.Parent.Parent.Parent.Home.Visible = true
end)
script.Parent.MouseButton1Down:Connect(function()
for i,v in pairs(script.Parent.Parent.Parent:GetChildren()) do
print(v)
if v.Name ~= "Selection" or v.Name ~= "Dragify" or v.Name ~= "UICorner" then
v.Visible = false
end
script.Parent.Parent.Parent.Home.Visible = true
end
end)
From what I can understand, You’re trying to set visible to true the Home frame once the homeButton is clicked and others set to false. so here’s what I did.
local UI_ScreenGui = script:FindFirstAncestorWhichIsA("ScreenGui") -- Why? Since there's only one main ancestor tht is a ScreenGui class.
local Main = UI_ScreenGui:WaitForChild("Main")
local thisButton = script.Parent -- The button
thisButton.MouseButton1Down:Connect(function()
for _, children in pairs(Main:GetChildren()) do
if children:IsA("Frame") and children.Name == "Home" then
children.Visible = true
break --// End the loop since it found the subject.
elseif children:IsA("Frame") and children.Name ~= "Home" then
children.Visible = false --// No break loops to prevent stopping the loop and other frames are still visible.
end
end
end)