Whenever the puck/ball goes near the AI, the AI starts to move back and forth for some reason. I am using a BodyPosition to control its movement. Is there any way to prevent the AI from doing this? The old variable is its original position from when the game first loads up and it never changes.
local u = (workspace.ball.ball.Position-script.Parent.Position).unit -- Script is located under the HRP of the AI if (workspace.ball.ball.Position-script.Parent.Position).magnitude > 7 then bodyPos.Position = old+u*10 else bodyPos.Position = old+u*(workspace.ball.ball.Position-script.Parent.Position).magnitude end