I have tried doing angle = math.atan2(vec2.Y,vec2.X) - math.atan2(vec1.Y,vec1.X) where vec2 is the upvector stuff and vec1 is the other vector.

However this is producing unreliable results as I need to rotate the character’s humanoid root part by the angle to align the gun to point towards the mouse hit position and when I use this method to get the angle needed to rotate, the character flashes and glitches around.

I’m getting an issue now where if I do composition of the humanoid root part’s CFrame with CFrame.Angles(0,anglebetweenvectors,0) I’m getting a black screen and seconds later my character is dying? (I assume I’m being flung somehow)

EDIT: I’m printing the output of the angle between two vectors function and I’m getting -NAN(ind)?

That means your input to math.acos is not within [-1, 1].

Make sure you are feeding non-zero vectors to the function and that you either use the function that takes both non-unit and unit vectors, or use the function that takes unit vectors but then ensure that your inputs are actually unit vectors (= length 1).

If that doesn’t solve the issue, it might be because of a floating point error, in which case clamp the value you feed to math.acos to be within [-1, 1]: