How to fix direction of target

I got this script which gets the direction towards the target so that I could move the character there but when the character reaches the destination, it starts to get buggy.

local vector = (WalkToPoint - origin) * Vector3.new(1, 0, 1)
local direction = vector.Unit

Video:

(0, 0, 0).Unit is (NaN, NaN, NaN). Try

local direction = vector.Magnitude > 0 and vector.Unit or Vector3.zero

I fixed it. It was the acceleration that was the problem.

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