Using existing class in other files as variable type?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Fedar

I need to store my existing player as a variable type in another file but when I try to use Player class program throws an error like:

Parse Error: The identifier "Player" isn't a valid type (not a script or class), or couldn't be found on base "self".

My OtherClass.gd is like that. How can I use Player class in other files?

extends Node

onready var Player = preload("res://resource/character/Player.gd")

var player: Player

func _ready():
	pass
:bust_in_silhouette: Reply From: njamster

Add the line class_name Player to your Player-script. However, be aware that the node will also show up as an option when you’re adding a new node to the tree.