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

Checking if there is a part at a position?

Asked by
gitrog 326 Moderation Voter
6 years ago

I want to know if there's a function or method to find if there is a part at a given position. I know you could create a part and check if it's touching anything, but that seems inefficient. Any ideas?

0
+1 cause you're an amazing soul and accepted mah answer Goulstem 8144 — 6y
0
+1 awfulszn 394 — 6y

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
6 years ago

You can use Region3.

Use the Region3.new constructor to create your region. Use the FindPartsInRegion3 function of workspace to get any object located inside of it.

Example;

local region = Region3.new(Vector3.new(0,0,0),Vector3.new(10,10,10))
local parts = workspace:FindPartsInRegion3(region)

for _,v in next,parts do
    print(v:GetFullName())
end
Ad

Answer this question