@Rinlore can you send the link to the level and I think you should just get the distance to the item and not if its a coin or not.
Just randomly collect stuff near you except mushrooms
you should do as you did on line 15 for the if-condition on line 10, you should make sure there is an item, (its type is equal to gem - you did that) or the distance is less than 20 meters