How do you detect parts around another part with a certain radius?

That sounds like it is not detecting what it is touching. Just put a touched event connected to the part anywhere in the script as long as it runs before the GetTouchingParts code.

    —do nothing

Edit: Don’t put it inside a loop, or you will end up with tons of connected Touched events sucking up CPU.


-- @param part BasePart The part used in the function.  You get all the touching parts of this part.
-- @returns Array<BasePart> The touching parts of the touch parameter
function getTouchingParts(part)
     local connection = part.Touched:Connect(function() end) -- needs a touch interest
     local parts = part:GetTouchingParts() -- get touching parts
     connection:Disconnect() -- remove connection
     return parts
1 Like

Not sure if this has been mentioned yet, but if you trace a circle and find the area of it, you can solve for what points are in the circle and what points aren’t.

The middle part would be your center or the center of the circle. Radius would be the distance from your center to the edge of the circle. Depending on what axis you’re on, if you take the diameter of your radius and solve for the arc-lengths for each of the quadrants in a 2D plane, that should make up a circle.

If you’ve taken PreCalculus, you could probably use the Unit Circle.

Another easier but, less cool method would be to take a cylinder with the same length and width (height would be shorter or equal to your character’s height). Taking this cylinder, you can CFrame it to the characters rootpart and use touched or Region3 to determine collisions.

Hope this helps!

1 Like

How would I put that into the script? I’m having problems figuring it out

Show us what you have so far, please.

Never mind, I just had a typo. Thanks for the help

1 Like