Vector3 unit returning nan

When I calculate unit in the script it return nan,nan,nan

  00:35:43.635  directionToMouse nan, nan, nan  -  Client - AttackVisualizationModule:66

but if I extract each one manually it return a Vector3

I don’t know why this is happening.

Could you share the script? Just copy 'n paste it inside of triple backticks ` ` `
Like so:

--this is a script

edit: Nan is created when you perform a mathematical operation that results in undefined, like 0/0 or log(x) with x < 0. Or if you perform an operation with Nan, so maybe check if the mouse position (or any of the operands) are NaN or a number that causes undefined.

1 Like

The code you’re running in console is not equivalent, your .Unit is in the wrong place. Unit returns 3 NaNs if there is one NaN in each axis in either side of the subtract, or if the length is zero, which means the vectors on either side of the subtract are exactly the same.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.