How to change Node variable name by other script

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

I want to change the variable name let me give you an example:

Player scene

var SPEED = 100
#Some Code in the player scene..

World scene

var power = "SPEED"
$Player.power = 200

Is this possible?
Is there any way to make it possible?
I hope you guys understand what i wrote am not really good at english/

I think I understand what you want to do, but I don’t know WHY you’d want to do that. Assuming your World scene has access to the Player scene, to change the value of the player’s SPEED variable from the world scene would just look like this:

$Player.SPEED = 200

Why do you want to reference it using a different name? That doesn’t seem to add any value and just creates a level of indirection that’s bound to lead to unnecessary confusion.

Can you explain what the purpose would be?

jgodfrey | 2023-06-02 18:55

i made a mistake i want to change the player variable value from another scene in the world scene

–>scene 1

anyways i found the answer

User5080 | 2023-06-02 19:09

:bust_in_silhouette: Reply From: User5080

Guys I found the answer of my question

$Player.set(power, 200)

So when set the power value to SPEED the Player variable you want to put will be changed to the power value for example you have speed and jump variables in the Player node and you want to change the jump value so you put

power = "jump"
$Player.set(power, 200)

by that the player jump value will be 200
and also if you want the same thing but with speed or something else you can just change power value.