Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Pet.on - how does it work? [SOLVED]

Hey guys,
I have had recently a problem with pet.on. How can I make that for example when my hero is attacking enemies, my pet fetches my coins? My current problem is that when I use pet.on my hero doesn’t attack and only the pet fetches coins. Is it a kind of a bug or maybe it should work like that? I can post the code if you want to.

Post your code here . No one has the right to post full working solutions but why something doesn’t work is an interesting challenge.

1 Like

I don’t want you to write my code, but to tell me how does pet.on work.

Nevermind, it seems to be a strange bug. Now it works correctly.

You’re trying maybe to use Mimic Pet to collect coins, right? I read this just now:
"The downside of using custom events:
Callbacks are synchronous. When called, your function holds all other processes until the callback function is run. Custom events stop the rest of a script from running while they dispatch, but any functions that listen for them run asynchronously. Often not a big deal, but if you need to stop other code from running until the callback is complete, custom events aren’t the right call. "