So im making a Tower Defense game based around noobs and guests, though, im having a problem making the noobs look at the guests, basically, in certain positions the noobs will get stuck in another orientation that isnt looking at the guests, yet, it only happens at those certain conditions, in the video, we can see that the top noob doesnt suffer at all from this bug but the bottom one does.
I used CFrame.fromMatrix() to accomplish this, also tried CFrame.new(Target,eye) which gives the same outcome as stated and CFrame.LookVector doesnt work at all, here´s the code:
module.Aim = function(Guest ,Tower) -- guest = target / tower = eye
local forwardVector = (Guest.Position - Tower.PrimaryPart.Position).Unit
local upVector = Vector3.new(0, 1, 0)
local rightVector = forwardVector:Cross(upVector)
local upVector2 = rightVector:Cross(forwardVector)
return CFrame.fromMatrix(Tower.PrimaryPart.Position, rightVector, upVector)
end