Help with funct

Why isn’t this function running when i click the Parent (it’s a text button)

script.Parent.MouseButton1Click:Connect(function()
local equipped = false
if swordname == player.equippedSword.Value then
	equipped = true
end
print(2)

-- equip the sword
--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)
1 Like

the first if statement returns false bcuz your comparing a Value with a string…i think

1 Like

Isnt it MouseButton1Down instead of click?

1 Like

I worked when I tried it.

Is this a Local Script inside of a button?

1 Like