So I have tried to use the Touched event and GetTouchingParts but none of them worked. Any other way I can detect them?
local Parts = --folder
for i,v in ipairs(Parts:GetDescendants()) do
if v:IsA("BasePart") then
local touchingParts = v:GetTouchingParts()
for _, part in pairs(touchingParts) do
print(part)
end
end
end
If two anchored parts are right next to each other, they won’t detect a touch. But if one of the parts are slightly inside the other, you can detect them using GetTouchingParts. I don’t know what you plan to use this for, but if you are using it for a building system of sorts, you could create a secondary, invisible part that will act as the touch detector of sorts.
Unfortunately, yes. If you wanted to do it otherwise then I believe the only way to do it is to make your own geometry collision detection. I believe EgoMoose has made a module that can do this, or you can make your own
I do recommend against it as there are very few scenarios in which you wouldn’t have geometry in the workspace
for i,v in ipairs(Parts:GetDescendants()) do
if v:IsA("BasePart") then
RotatedRegion3.FromPart(v)
local parts = RotatedRegion3:FindPartsInRegion3WithWhiteList(castParams.FilterDescendantsInstances, maxParts)
print(parts)
end
end
You could size the part trying to detect what’s near it up by .01 for an instant to see if anything’s touching it in the immediate area.
Try this:
local Parts = --folder
for i,v in ipairs(Parts:GetDescendants()) do
if v:IsA("BasePart") then
v.Size = v.Size + Vector3.new(.01,.01,.01)
local touchingParts = v:GetTouchingParts()
v.Size = v.Size - Vector3.new(.01,.01,.01)
for _, part in pairs(touchingParts) do
print(part)
end
end
end