How to change script variables from another script?

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

So if your confused with the title. Basically lets say I have a script called A.gd and B.gd. How can I change a variable in B.gd using A.gd? This is vital part of my hitscan weapon system I just want to know.

:bust_in_silhouette: Reply From: kidscancode

Scripts are just files sitting in the project folder. They don’t do anything on their own. They either define custom objects or are attached to nodes. The latter is far more common, so what you really have is node A and node B.

Nodes live in the scene tree. To communicate between nodes, you either use signals or get_node(). To be more specific, you’d need to describe your actual setup.