how do i get a variable from another script?

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

I’m trying to display a var as text in a different node and need the var from the player one

I’m a beginner, so I could easily be wrong, but at the top of the script, where it says "extends ‘X’ ", you can type in the script you want the variable from.

Slow’n’Steady | 2021-04-19 02:32

the extends x is what the script is attached to, so that wouldn’t work. Thanks though!

Bacon_Gb12 | 2021-04-19 02:35

I skipped the Extends Node but I think you can get it.

Bubu | 2021-04-19 13:06

:bust_in_silhouette: Reply From: Bubu

Get the node that has the variable and then reference it like any other property.

Here’s an example:

var property = "some property"

onready var player = $Player
var property =

I’m fairly new to Godot, can you explain how I do that? you could just give me an example if you want. Thanks!

Bacon_Gb12 | 2021-04-19 01:49

Already did. Refresh the page.

Bubu | 2021-04-19 01:50