Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
oreoollie 649 Moderation Voter
4 years ago
Edited 4 years ago

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.

0
so, how to check if the part is inside the radius do I do if part.Position == (part1.Position - part2.Position).Magnitude? shanelaw12 64 — 4y
0
(part1.Position - part2.Position).Magnitude is the distance between the two positions, so you need to compare it to the radius you want. oreoollie 649 — 4y
Ad

Answer this question