Do you load a level/room scene and then instantiate the player scene in it?
In that case you can use the child_entered_tree signal nodes have:
The script on the room/level scene where I add the player for testing:
extends Node2D
const PLAYER = preload("res://Player.tscn")
func _ready() -> void:
child_entered_tree.connect(check_child) # Or connect via inspector
var player = PLAYER.instantiate()
add_child(player)
func check_child(node: Node):
# check via group
if node.is_in_group("player"):
print("node is in group player")
# or via class
if node is Player:
print("node script has class player")
Player script needs class_name to check class with "is"
class_name Player extends CharacterBody2D
prints:
node is in group player
node script has class player