Better way of handling Pet Equip/UnEquip

As of right now I’m handling the unequip/equip with just text,as of right now,it kinda works but sometimes it dosent


--SelectNamePet is a value so that when you click the viewport frame of pet,it gets that pet and sets the value of SelectNamePet to the pets name
	petEquip.MouseButton1Click:Connect(function()
		local petNew = game.ReplicatedStorage:WaitForChild("Pets"):FindFirstChild(SelectedNamePet.Value):Clone()
		if script.Parent.Parent.Parent.MainUI.PETINV.PETINVFRA.INSF2.Equip.EquipTEXT.Text == "EQUIPPED" then
                PetFolder:WaitForChild(SelectedNamePet.Value):Destroy()
				game.ReplicatedStorage.Events.UnEquipPet:FireServer()
			script.Parent.Parent.Parent.MainUI.PETINV.PETINVFRA.INSF2.Equip.EquipTEXT.Text = "EQUIP"
		else
				script.Parent.Parent.Parent.MainUI.PETINV.PETINVFRA.INSF2.Equip.EquipTEXT.Text = "EQUIPPED"
				setTempEquip(TempClone)
				petNew.Parent = PetFolder
				game.ReplicatedStorage.Events.EquipPet:FireServer(SelectedNamePet.Value)
		end
	end)
end 

2 Likes