Why is my Variable not in scope?

Hi everyone!

So i’ve checked forums, vid tutorials, and answerhub and I just can’t seem to find the answer.

I have a bool variable that I switch on and off from my blueprint class, that I need to reference into the level blueprint.

In the Level Blueprint I wanted to run one of two option depending on that same variable.
Unfortunately when I compile and run it, it shows that it’s always taggled off, and when i hover over “GoggleOn?” in the Level Blueprint, it says “variable is not in scope”. Any ideas of what could be the problem?

I’ve had this a few times and for me it’s seems to be when the variable isn’t being bound/referenced as intended. It could be that your GoggleOn? variable isn’t being read properly from your Kobu Reference. I’m very new to visual scripting so not sure how much I can help but perhaps try creating a local variable which you can Cast to from your Level BP. I’ve found getting communication a bit hard to get my head around. But i’ve managed to do similar by keeping inventory of items to pickup in a level and posting messages like “3 objects left” etc. The key ways I know so far are:

  • BP Interfaces.
  • Using a function (press the +f next to new variable)
  • Cast from one to another
  • Create a variable with type set to the BP Class you want access to (I think this is what you’ve done)

By using your method I also had a similar problem. Perhaps try one of the other methods until some one more knowledgeable can help out. Creating a function is good because you can call it from other classes easily. Same with BP Interfaces

Anyone have a resolution for this?

I think Pixeldamage has good advice for the out-of-scope watch variable problem. I would also like to see the debug watch feature become more robust as it is an invaluable tool.

The reason your graphs don’t function properly might be due to using the latent delay node in your tick event. In general, you probably shouldn’t be using latent nodes (the ones with the clock icon in the upper right) in your tick events. You could use the timer manager to fire periodic events like this:


Mmm I am not using a delay node but still get the out of scope problem… :stuck_out_tongue:

What exactly does “Out of Scope” mean?

This video should help answer your question about Scope:

This video explains scoping mechanics in C++, not blueprint script.

The principle is the same.
In C++, If you declare a variable inside one function, other functions can’t use that variable because it’s out of scope.
In blueprint, if you declare a variable inside one blueprint, the other blueprints can’t use that variable because it’s out of scope.

Is because everything without the white arrow connector is basically just a variable declaration (or the return value of a function in some cases)

So what you have to do is to create a function, because this way you ask for the variable every time you call the function. So first you have to declare the function (click on the ƒ+ to create one) and specify one output parameter (boolean) then set it up like you see here. After that just call that function from the event graph.


There are many similarities with c++ but other blueprints can see any variable on the other instances (unless those are set to “private”) but the default behavior is for every variable to be public. In this case the problem was not using a function of other sort of mechanism to get the current (not the old) value

Yep, see my answer below. (I tested it)

I am actually having a similar problem even though I am using functions AND local variables.

When I call the function in multiple succession, each successive call is updating the same set of variables even though they are local in scope.

Yeah, that was it for me, as a programmer I fnid that weird that it does that only once…absolutely having a Getter function can be a good habit, but it’s still weird

Im very new to blueprint so please bare with me :slight_smile:
But where do you create the variables if you want other blueprints to access them?


Why not convert Google On? to a pure function?

Could be; I just wanted to get the point across of what’s happening and how to fix it; adding arguments to the function just makes it more confusing for beginners.

Any idea if the new watch window system in 4.20 will alleviate this, or if it will always be an issue?