Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do I check if a part is inside a certain radius?

I've tried experimenting with many things, but nothing worked. Idk if I the methods I tried were correct but I used them wrong, or they were wrong. Can someone help?

1 answer

Get the difference of the vectors then get their magnitude via Vector3.Magnitude. Here's an example of that:

local part1 = workspace.Part1
local part2 = workspace.Part2

print((part1.Position - part2.Position).Magnitude)

If my answer solved your problem please don't forget to accept it.

2 comments

0

so, how to check if the part is inside the radius do I do if part.Position == (part1.Position - part2.Position).Magnitude?

0

(part1.Position - part2.Position).Magnitude is the distance between the two positions, so you need to compare it to the radius you want.

This discussion is preserved as it was. New answers, comments, and votes are closed.