March 23, 2020, 12:31am
I was attempting to utilize something with :GetTouchingParts(), but I encountered while playing in Studio, that although the red part (seen above) is intersecting with the “slot” part, the print is showing that there are 0 touching parts.
Can anyone explain this to me?
The part needs to have CanCollide set to true or be connected to a touch event (like Touched or TouchEnded) BEFORE calling GetTouchingParts()
If the CanCollide is false, then
GetTouchingParts() will return nil.
Here’s something that may help you:
Suppose you have PartA and PartB in workspace that intersect, but both are non-CanCollide (or only one of them is non-CanCollide):
You might know that the following call will not yield any results in that case:
local results = workspace.PartA:GetTouchingParts()
print(#results) --> 0
However, if you attach an empty Touched handler before the call and disconnect it afterwards, all intersecting parts are returned:
local function GetTouchingParts(part)
local connection = part.Touched…
March 23, 2020, 12:38am
In order for GetTouchingParts to work properly you must have a listener connected to the Touched event.
local signal = part.Touched:Connect(function() end)
local touching = part:GetTouchingParts()