I'm not 100% sure with my observation but it worked.
I had a problem of market getting stuck when buying ammos in market,
When buying an ammunition in market, and auto refill ammo is ticked, i think bot is trying to equipped the ammunition from inbox while the market is open which makes the bot unable to close the market.
buyitemsmarket(ammoname, maxammoprice, amountofspear)
stopattack()
closemarket()wait(200)
I added stopattack to check if really bypass the buyitems, it didnt worked.
I tried put code to untick it before it buys and retick it after buying, it worked.