Common issue with smelting and animation-related scripts,
the usual response you will get, is to make a timer, so every time the animation isn't -1, set a timer for a few seconds which will count down. If timer reaches 0, it means you aren't smelting anymore, if the timer is above 0, make the script sleep.
Or, another perspective is to flag the player when smelting event begins, and only un-flag it when certain criteria are met; e.g. user run out of ore, user isn't interacting etc.