Attempt to index field (a number value) during rewrite (SOLVED)

I’m currently rewriting the player code of my game to include a state machine, In doing so I no longer get self.velocity to function in my new version. While it still works in my old version

they are both first defined in init as self.velocity = vmath.vector3(0,0,0)
and are both doing the same tasks

the only difference I can see is that I’m using it in a function out of the update function rather than in update itself

for reference the error line is “local speedDiff = target_speed - self.velocity.x”
which is templated off the bunny game in the learn section

Have you tried printing self.velocity to find its value? The error message tells me it’s a number, not a vector. In that case, try to figure out what part of your script makes this happen.

found it, I realised I put self. Velocity = 0 in one of my messages