When trying to assign variables in a class, they're returning as null or blank later on, despite being confirmed to be assigned. Here's an example, where kx is a string with value 0001:

var key: String

...

func my_function(kx: String):
    print(kx) # prints "0001"
    key = kx
    print(key) # prints "0001"

When querying this value in _physics_process(), it returns as a blank string. I've observed similar results when assigning other types of variables.

I've probably missed something stupid, but nonetheless does anyone know the issue?

I'm not sure. That example looks like it should work. Are you modifying the value elsewhere?

This is hard to answer without seeing all of your code.

Is "key" assigned a value before _physics_process() is called?

cyberreality: it is not being modified elsewhere, no.

DaveTheCoder: yes, the variable is not assigned at any other point in the code, it is only accessed during _physics_process().

In the code you posted, the variable is being assigned a value inside a function, but the function isn't called. Is the function called somewhere, such as in _ready(), before _physics_process() gets called?