Here is my script:
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
local gett = script.Parent:GetTouchingParts()
for i,v in pairs(gett) do
print(v.Name)
end
end)
It doesn't work.
Here is my script:
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
local gett = script.Parent:GetTouchingParts()
for i,v in pairs(gett) do
print(v.Name)
end
end)
It doesn't work.
If you read the reference page for GetTouchingParts(), you'll see that if the "part itself has CanCollide set to false, then this function will return an empty table unless it has a TouchInterest." In order to insert a to fix your problem, you can temporarily connect a listener to the part's Touched event, call GetTouchingParts(), and then call Disconnect() on the RBXScriptConnection (as highlighted here).
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
local connection = script.Parent.Touched:Connect(function() end)
local gett = script.Parent:GetTouchingParts()
connection:Disconnect()
for i,v in pairs(gett) do
print(v.Name)
end
end)
If you ever need to permanently connect an event listener to the Touched event, remove this fix because it will interfere with the actual event listener.
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
Oh wait. The part had cancollide off. Is there a way to get the touching parts if the part has cancollide off?
if it is a block and you didn't rotate it, you can try region3
if it is a block and you didn't rotate it, you can try region3
magnitude