How to make my coins respawn after being collected

Hey there!

So I’m making a very simple map where players have to go around collecting coins that are worth a set amount of points. First player to get to 200 points wins.

I want the coins to respawn after they are collected but to add a timer so it doesn’t respawn immediately. What I tried to do in Verse was the following

OnBegin<override>()<suspends>:void=
        for (Coin : CollectibleCoins) :
            Coin.CollectedEvent.Subscribe(RespawnCoinFunction)

RespawnCoinFunction(InCoin : agent)<suspends> : void =
        Sleep(20.0)
        # Respawn the coins here

The error I’m getting is the following:
“This function parameter expects a value of type agent->void, but this argument is an incompatible value of type type{_(:agent):void}.”

Apparently I can’t use a function with as a callback for Subscribe but I’m not really sure why. Can anyone suggest a better way to do this?
Thank you

The event CollectedEvent needs to be subscribed with a function that matches its listeneable signature, so your Subscriber cannot have the <suspends> specifier

This should work :

Coin.CollectedEvent.Subscribe(RespawnCoinFunction)

RespawnCoinFunction(InCoin : agent): void =
    spawn{_RespawnCoinFunction(InCoin)}

_RespawnCoinFunction(InCoin : agent)<suspends> : void =
        Sleep(20.0)
        # Respawn the coins here