Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I prevent my AI from doing this?

Asked by
poke7667 142
3 years ago
Edited 3 years ago

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

AI Bugging Out

Answer this question