Var From Another Script Doesn't Update

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

I Have This Script Called “Game” That Have The Variable “hit” and i put the Script on AutoLoad So I Can access it from another scripts
on “Game

func _Right_Enter(body):
if body.name == "Player":
	hit = true
##########################
func _Right_Exit(body):
if body.name == "Player":
	hit = false

The Hit is Working Very Well if I Print it on The “Game” Script
but when I put the hit on Another Script it keep giving me Null (The First Value of hit) and doesn’t update to true of false

So What’s The problem here ?

:bust_in_silhouette: Reply From: Gluon

Try this

func _Right_Enter(body):
    if body.name == "Player":
        Game.hit = true
##########################
func _Right_Exit(body):
    if body.name == "Player":
        Game.hit = false

Thanks This Will Fix All of My Other Scripts as well haha

miuatoro | 2022-12-30 18:44

No problem, good luck with your game

Gluon | 2022-12-30 19:51