Getting the distance beetween two points

Hi, i’m trying to get the distance between my mouse (position) and a Part (Point).
It seems correct but when i try to print “magn” it gives me the distance between the mouse and the origin(0,0,0).

This is the code

local magn = math.abs((position - Vector3.new(Point.CFrame)).Magnitude) 

What I’m doing wrong?

returns 0, 0, 0 if you want to get the position from the cframe do CFrame.Position

local magn = math.abs((position - Point.CFrame.Position).Magnitude) 
1 Like

oh damn I’m stupid…
It worked thanks

I am pretty sure that .Magnitude is always a positive value?

1 Like

Yes, magnitudes are always positive.

@NickNessunTipo you can remove the math.abs.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.