Ah, I see an issue. In your Coin.gd, you left
queue_free() outside of the if loop.
if body.name == "player":
That's all I would do. If the system fusses, try putting the Player scene into a Group called "player", and change
if body.name == "player" to
In mainscene.gd, I'd put
randomize() into the
_ready() function, and have
var coin_scene = preload("res://scenes/coin.tscn") between the topmost function, and the
Apologies if this is a bit of a mess.