You need to give some more detail on your setup and what, exactly, you’re doing:
But common reasons for such errors are
The variable in question is currently out-of-scope
The variable in question has been optimised-out
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.