- Edited
I'm trying to make a tool-type scene that I can use in the Editor for designing levels. This scene has an exported variable that I can change in the editor and that is, when changed, meant to send signals to other nearby scenes (in the same sub-node as this scene). Think a switch with an "edible" boolean (so like true = "good" and false = "rotten") that transforms all the food in the scene from "poisonous" to "edible" and the other way around when switched.
As part of making this tool, I started by adding a setter to the variable, like this:
@export var pressed : bool :
set(new):
pressed = new
if new == true:
get_tree().call_group("food", "edible") # "food" is the Group that has a function "edible" that switches it from rotten to edible and the other way around
So this crashes in the last line with a Cannot call method "call_group" on a null value
. Calling the same group using the same line elsewhere in the same script works perfectly. Does this mean I can't call a group from a setter? What am I doing wrong?