After playing around a bit with raycast I figured out a way to solve this without messing around with collision masks (which you should probably learn but I think this is a great alternative for some reasons). Of course, I've only tested this in 2d.
I have a scene with a KinematicBody2D (Goomba or any other enemy) and in it's _ready function I've added the next line of code which will later be handy in the Mario scene:
Now in my Mario scene with a KinematicBody2D node, to which I've attached a RayCast2D node (the "stomp detector"), I have the next code in the physicsprocess function:
var collider = $RayCast2D_Stomp.get_collider()
jump(jump_speed * 0.75)
As you can see, you simply get the collider that the raycast has detected and check if it is in a certain group, if so, you go ahead and execute the code you want. This is very handy since you can even call functions from the collider, in this case, i called the die function from the Goomba node Mario has stomped on.