You didn't say where exactly in that code the error is happening.
One thing I notice: you use
set_pos() requires an argument - you have to set the position to something.
var spawnInstance = spawnReference.instance()
Is not a good thing. You're spawning an instance of that scene every time the input function is called. But that happens on any input event, including mouse movement, etc.
In general, it's a better idea to use the input map and create input actions for any input you want to process. That way it's easier to change input keys, transition to gamepad or touch, etc.