arguments for creation of a scene

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

How do i send arguments with the creation of a scene?
for example: i want to create a scene, but i want to tell that scene that the player level should be 2

:bust_in_silhouette: Reply From: Ertain

Does the scene have a script attached to it? If so, properties can be assigned when the scene is loaded, added to the scene tree, or at other times. Here’s an example.

## This is in a top level node with a script attached. ##
func _ready() -> void:
    # We have a child node that needs to be assigned something. Here, the `player` node has a property `level` that needs to be assigned a number.
    $player.level = 2

The $player node has a script attached to it with a variable level. When the top level node is ready, it assigns 2 to the level property.

Hope that clears things up.