Some frame visibility not turning false

I made a script where when you touch a block you get a sword and all ui visibility goes invisible and I made another block when you leave only 3 ui get visible but not the rest but the frames rent turning invis, the scripts are below. What am I doing wrong?

Give swordand ui invisible script

script.Parent.Touched:Connect(function(hit) -- The part has been touched
	if hit.Parent:FindFirstChild("Humanoid") then -- The touched's parent has a humanoid in it
		local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Getting the player by the character (the hit.Parent is our player in this case)
		local weapon = game:GetService("ReplicatedStorage"):FindFirstChild("ClassicSword")
		local mewgui = player.PlayerGui.resetonspawn.MewClick
		local pushupcui = player.PlayerGui.resetonspawn.PushUpClick
		local squintclick = player.PlayerGui.resetonspawn.SquintClick
		local mewselect1 = player.PlayerGui.resetonspawn.MewSelect1
		local mewselect2 = player.PlayerGui.resetonspawn.MewSelect2
		local pushupselect1 = player.PlayerGui.resetonspawn.PushUpSelect1
		local pushupselect2 = player.PlayerGui.resetonspawn.PushUpSelect2
		local squintselect1 = player.PlayerGui.resetonspawn.SquintSelect1
		local squintselect2 = player.PlayerGui.resetonspawn.SquintSelect2
		
		if player then -- If the player is here
			game.ReplicatedStorage.weapongive:FireClient(player) -- Put in the event name your remote event's name, this fires the event.
			mewgui.Visible = false
			
			pushupcui.Visible = false
			
			squintclick.Visible = false
			
			mewselect1.Visible = false
			
			mewselect2.Visible = false
			
			pushupselect1.Visible = false
			
			pushupselect2.Visible = false
			
			squintselect1.Visible = false
			
			squintselect2.Visible = false
			local Find = player.Backpack:FindFirstChild("ClassicSword")
			if not Find then
				local find1 = player.Character:FindFirstChild("ClassicSword")
				if not find1 then
					weapon:Clone().Parent = player.Backpack	
				end
			end
			
		end

	end
end)

destroy sword script and only 3 UI reappear

script.Parent.Touched:Connect(function(hit) -- The part has been touched
	if hit.Parent:FindFirstChild("Humanoid") then -- The touched's parent has a humanoid in it
		local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Getting the player by the character (the hit.Parent is our player in this case)
		local mewgui = player.PlayerGui.resetonspawn.MewClick
		local pushupcui = player.PlayerGui.resetonspawn.PushUpSelect1
		local squintgui = player.PlayerGui.resetonspawn.SquintSelect2
		local pushclick = player.PlayerGui.resetonspawn.PushUpClick
		local pushselect2 = player.PlayerGui.resetonspawn.PushUpSelect2
		local squintclick = player.PlayerGui.resetonspawn.SquintClick
		local squintselect1 = player.PlayerGui.resetonspawn.SquintSelect1
		local mewselect1 = player.PlayerGui.resetonspawn.MewSelect1
		local mewselect2 = player.PlayerGui.resetonspawn.MewSelect2
		if player then -- If the player is here
			game.ReplicatedStorage.weapontake:FireClient(player) -- Put in the event name your remote event's name, this fires the event.
			mewgui.Visible = true
			pushupcui.Visible = true
			squintgui.Visible = true
			pushclick.Visible = false
			pushselect2.Visible = false
			squintclick.Visible = false
			squintselect1.Visible = false
			mewselect1.Visible = false
			mewselect2.Visible = false
				local Find = player.Backpack:FindFirstChild("ClassicSword")
	if Find then
		Find:Destroy()
	end
	local Find1 = player.Character:FindFirstChild("ClassicSword")
	if Find1 then 
		Find1:Destroy()
	end

		end

	end
end)

ScreenGuis to become invisible, you need to do screenGui.Enabled = false. Yeah, you can’t do screenGui.Visible = false.

In order to make a UI disable and a UI enable, you must use the property “Enabled” in the ScreenGuis as Visible isn’t a property of a ScreenGui, you can also use for I loops to disable all the ScreenGuis to further optimize your script

Here’s what I came up with:

Close all UI and give you a weapon:

script.Parent.Touched:Connect(function(hit)
	if game.Players:GetPlayerFromCharacter(hit.Parent) then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		local playerUI = player:WaitForChild("PlayerGui")
		local weapon = game.ReplicatedStorage.Sword -- Put the weapon's name here
		
		for i,v in pairs(playerUI:GetChildren()) do
			if v:IsA("ScreenGui") then
				v.Enabled = false
			end
		end
		
		if not player.Backpack:FindFirstChild(weapon.Name) and not player.Character:FindFirstChild(weapon.Name) then
			local newWeapon = weapon:Clone()
			newWeapon.Parent = player.Backpack
		end
	end
end)

Enable the UIs you want by putting their names in the “UiWhitelist” Table:

local UiWhitelist = {"MewClick", "PushUpSelect1", "SquintSelect2"} -- The name of the ScreenGui(s) you want enable

script.Parent.Touched:Connect(function(hit)
	if game.Players:GetPlayerFromCharacter(hit.Parent) then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		local playerUI = player:WaitForChild("PlayerGui")
		local weapon = game.ReplicatedStorage.Sword-- Put the weapon's name here
		
		for i,v in pairs(playerUI:GetChildren()) do
			if v:IsA("ScreenGui") and table.find(UiWhitelist, v.Name) then
				v.Enabled = true
			else
				v.Enabled = false
			end
		end
		
		
		
		
		if player.Backpack:FindFirstChild(weapon.Name) then
			player.Backpack:FindFirstChild(weapon.Name):Destroy()
		elseif player.Character:FindFirstChild(weapon.Name) then
			player.Character:FindFirstChild(weapon.Name):Destroy()
		end
	end
end)