Raycast collider not working as expected

Godot Version

4.3.stable

Question

if head_bump_ray_cast.is_colliding():
	var collider = head_bump_ray_cast.get_collider()
	if collider.is_in_group("enemy"):
		print("hit")

So for some odd reason this collider just doesn’t work even tho it’s turning red on collision and it clearly collides with the enemy, also trying to get the name using collider.name only returns @StaticBody2D for the enemy but returns the actual name for other nodes. Any ideas?

Can you expand on how it is not working? Please post exact error messages, if any.

It would also help if you include the scene tree of the objects that are meant to collide.

This is the player and It’s RayCast which is pointing straight up -60px.

I have a script that spawns platforms above the player and enemies on them.
This is the script:

func _spawn_platform() -> void:
	# Spawn platform
	var new_platform = PLATFORM.instantiate()
	if is_first_platform:
		is_first_platform = false
		new_platform.position.y = last_platform_pos.y
	else:
		new_platform.position.y = last_platform_pos.y - DISTANCE_BETWEEN_PLATFORMS	
		
	last_platform_pos.y = new_platform.position.y
	new_platform.add_to_group("platform")
	platforms.add_child(new_platform)

	# Spawn ninja frog enemy
	var chance = randf_range(0.0, 1.0)
	
	if chance <= NINJAFROG_SPAWN_CHANCE:
		var new_ninjafrog = NINJA_FROG.instantiate()
		new_ninjafrog.position.y = last_platform_pos.y
		new_ninjafrog.add_to_group("enemy")
		enemies.add_child(new_ninjafrog)

This is a screenshot of the game with visible collision shapes enabled.
The RayCast is colliding with both with the platform and the enemy.

Then there’s the code for the RayCast which run’s in to players script but the problem is that it just does not want to return the group of the collider.

There’s no error messages just null