I’m trying to find the distance of something from a part, but the part is shaped like a rectangle, so if it’s right up against the surface of the part, it will say different distances for each part on the surface because it is measured from the center, which I don’t want. The problem is, I have no idea how to find the distance of something from a part’s surface, so how do I do this?
Sounds like raycasting might be what you’re looking for: Raycasting | Roblox Creator Documentation
Make a ray pointing from the part you want the distance to (PartA) in the direction of your origin (rectangle) part (PartB). Then, get the Normal (Vector3) of the hit, then subract that Vector3 from the Vector3 of the part you want the distance from (PartA). So you end up getting: (PartA.Vector3 - Normal.Vector3).Magnitude is your distance
2 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
