How to prevent Ui Overlapping

So I want it so my ui’s to close whenever a different one opens and I can’t really figure it out.

Here is my script:

local main = script.Parent.Main

local weapon = main.Choose.Weapons
local setting = main.Settings.Settings
local update = main["Update Log"].Frame

if weapon.Visible == true then
	setting.Visible = false
	update.Visible = false
end

if setting.Visible == true then
	weapon.Visible = false
	update.Visible = false
end

if update.Visible == true then
	main.Visible = false
	setting.Visible = false
end

I know the script looks like it’s made by a beginner and all but can anyone tell me what I have to do

make a function called “SwitchUI” and it turns off the other ui’s and turns on the one you want

Try using this instead

local main = script.Parent.Main

local weapon = main.Choose.Weapons
local setting = main.Settings.Settings
local update = main["Update Log"].Frame

if weapon.Visible == true then
	setting.Visible = false
	update.Visible = false
    elseif setting.Visible == true then
        weapon.Visible = false
	    update.Visible = false
        elseif update.Visible == true then
	        main.Visible = false
	        setting.Visible = false

don’t know if copying and pasting that will work, but you get the point, use elseif, not just if