As you suggested, I think your problem is that your player variable points to the definition of the player scene not the actual instance of that scene in your world.
You need your player variable to be a reference to the player object when that has been instantiated in the world (in the scene tree).
One way to do it is to
1) at the top of your script, change your definition of the player variable to simply declare the player variable (null), not define it (because it won't be instantiated until the node tree is created in game)
var player : Object = null
2) in your ready function you can set _player (it will have been instantiated at this point)
player = $"/root/World/player" [I do not know how you have setup the player in your node tree, so change this to the path to your player kinematicbody
These are the docs about using nodepaths here
Hard-coding a nodepath like this is fragile since you will need to update that it if you change where you player is in the tree. So you will probably want a more reliable method to figure out where the player object is in the tree. Documentation for other approaches is here