I am trying to calculate the angle between two “2D” vectors (3D vectors excluding the XZ plane).
The first vector a is the position of a part, while vector b is the player’s mouse.Hit.p.

This is my code so far:

local a = script.Parent.Position
local b = mouse.Hit.p
local index = math.acos(a:Dot(b)/(a.Magnitude*b.Magnitude))
local angle = math.deg(index)

Personally not sure what you’re currently doing, but I would try using tangent.
You would actually want to use atan2 and pass it like math.atan2(B.y - A.y, B.x - A.X) iirc.

Okay, I’m back. Your code works, though the result may be in degrees already, so be sure to check on that. Also note that the position of the angle (per say, can’t remember the math word) is at the origin with your current code. If you want the position to be somewhere else, do this: a = otherpos - script.Parent.Position b = otherpos - mouse.Hit.p