The title says it all, I already have a position and the block, just need a way check if the position is inside the block.
The best I could do was to try to use Region3:FindPartsInRegion(), but it didn’t work for me. Here’s the code for the region3 script I tried to use:
local pos = Vector3.new(0,1,0) -- not the actual position
local region = GetFromRegionsTable(regionName)
local parts = game:GetService("Workspace"):FindPartsInRegion3(region)
for _,part in pairs(parts) do
if part.pos == pos then
print("Found part inside region!")
Well, you won’t be able to accomplish this that way, comparing CFrames directly won’t be of help since you’ll have to account for not only position, but rotation, and what are the chances of parts in there matching the position and rotation?
I am not sure how you make your Region3’s but you could try raycasting to see if you hit any parts inside the region.
Here’s a slightly modified code snippet I use from some post on some thread by Davidii
local function partIntersectsPoint(part, point, shape)
local delta = part.CFrame:pointToObjectSpace(point)
delta = Vector3new(abs(delta.X), abs(delta.Y), abs(delta.Z))
local halfSize = part.Size / 2
if shape == Enum.PartType.Block then
local inX = delta.X <= halfSize.X
local inY = delta.Y <= halfSize.Y
local inZ = delta.Z <= halfSize.Z
return inX and inY and inZ
elseif shape == Enum.PartType.Ball then
local inR = delta.magnitude <= halfSize.X
works for blocks and balls, and pretty easy to adapt it to cylinders or wedges.