Multiplayer treasure grove code "too slow"

My code runs for a few times, and then I get an error message that my code is too slow or an infinite loop. I used parts of my code from “diamond dozen” to prioritize the higher value coins. Here’s my code.
[Mod edit: Seems like the code worked. Just that there was a random bug in the game itself]

Hey there! It seems like the code does work and there’s no error in it. It’s probably because there was a random bug triggering an infinite loop. But no worries!