Problems with magnitude script

The script is supposed to check the distance between part A and part B, however, when the parts are further apart it still prints “Close, Within Studs”

image

Edit: This should be a Roblox Studio bug

Are you sure that the parts are more distant then 20 studs? I’ve analyzed your script, and nothing seems to be off. Try adding this line into your script to find out:

local dist = (Part1.Position - Part2.Position).Magnitude
if (dist < 20) then
    print("Close, Within Studs, Dist is",dist)
end

I’m not certain if you’re allowed to have a space in between the parentheses and the “.magnitude”.

I would try removing the space, and capitalizing Magnitude since it’s better form.

Hope this helped.

1 Like