Help with equip script

First bit works fine, the ‘Click Again To Equip’ appears but when clicked nothing happens?! Can anyone help me fix

local frameopen = false
local player = game:GetService("Players").LocalPlayer
local swordname = script.Parent.Parent.name.Text
local equipped = false
if swordname == player.equippedSword.Value then
	equipped = true
end

script.Parent.Parent.OGEQUIP.MouseButton1Click:Connect(function()
	if script.Parent.Visible == false then
		equipped = false
		if swordname == player.equippedSword.Value then
			equipped = true
		end
		
		frameopen = false
		if script.Parent.Visible == true then
			frameopen = true
		end
		
		if not frameopen  then
			
			for i,v in pairs(script.Parent.Parent.Parent:GetChildren()) do

				if v.Name == "SwordItem" then
					
					v.EQUIP.Visible = false

				end

			end
			
	
			frameopen = true
			if script.Parent.Parent.delete.Visible == false then
				frameopen = true
				script.Parent.Visible = true
				script.Parent.Text = "Click Again To Equip"
			end
		
				

		else
			frameopen = false
			script.Parent.Visible = false
		end
	end
end)

script.Parent.MouseButton1Up:Connect(function()
if script.Parent.Visible == true then
local equipped = false
if swordname == player.equippedSword.Value then
	equipped = true
		end
		
		
		player.equippedSword.Value = swordname
		
		
	for i,v in pairs(script.Parent.Parent.Parent:GetChildren()) do
	if v.Name == "SwordItem" then
		v.TickIfEquipped.Visible = false

	end

end
script.Parent.Visible = false
frameopen = false
equipped = true
script.Parent.Parent.TickIfEquipped.Visible = true
		end
end)