Hello! I'm pretty new to programming and I'm trying to create an Gui script which don't need an script in every frame. This is one of many options i've tried so far:
local MainGui = script.Parent.MenuGui
MainGui.Position = UDim2.new(0.5,0,0.5,5)
MainGui.AnchorPoint = Vector2.new(0.5,0.5)
MainGui.Size = UDim2.new(0, 500, 0, 500)
local opvv = script.Parent.opv.Value
for i,v in pairs(script.Parent.MenuGui:GetChildren()) do
v.Gui.Visible = false
v.Size = UDim2.new(0,200,0,50)
v.MouseButton1Click:Connect(function()
print(v.Name)
local gui = v.Gui
if gui.Visible == false then
gui.Visible = true
opvv = opvv + 1
while true do wait()
if opvv >= 2 then
gui.Visible = false
opvv = opvv - 1
end
end
elseif gui.Visible == true and opvv == 1 then
gui.Visible = false
end
end)
end

1 comment
If you don't know how, then refrain from replying.