Hey guys. I have this system I’m working on and it’s pretty inconsistent. I’m trying to make it so that when the player moves either towards, away, left or right from a part, it detects the direction the player is moving in and returns it with a print.
The issue is that it’s very inconsistent so at times you could be moving forwards and it’ll print out that its moving backwards and you could be moving back and it’ll print out that its moving to the right or the left.
Here’s a clip of the issue:
Here’s the code:
local dir = {
root.CFrame.LookVector,
-root.CFrame.LookVector,
root.CFrame.RightVector,
-root.CFrame.RightVector
}
local h
for i, v in pairs(dir) do
if (v - goal.CFrame.LookVector).Magnitude < humanoid.MoveDirection.Magnitude then
h = i
end
end