Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to get Touch Interest or how to use :GetTouchingParts() if part has CanCollide to false?

The reason I want Touch Interest is because I am making a script on which if you touch a part it will print out all of the parts touching it, so the way I made this was by using :GetTouchingParts() which will return a table which I can run through a in pairs loop to print all the parts, the problem is that the part that is being clicked has CanCollide to false so :GetTouchingParts() will always return an empty table which is not what I want, I read more about it and it said that It would do its thing if the part has Touch Interest? https://developer.roblox.com/en-us/api-reference/function/BasePart/GetTouchingParts Here is the script I used if you can spot any problems or make it more efficient. I have a MouseDetector inside the part and the script inside the Mouse Detector for more info.

script.Parent.MouseClick:Connect(function()
	local TouchingParts = script.Parent.Parent:GetTouchingParts()
	
	for i, v in pairs(TouchingParts) do
		print(v.Name)
	end
end)

1 comment

0

Well The Instance 'Touch Interest' can only be created when a Handle is inside a tool. After it is created, drag the Touch Interest To something else.

1 answer

It is written on Roblox's Api References that GetTouchingParts() will not work unless it has CanCollide set to true. .If you want to get the touching parts you meed to use TouchInterest. But if you want to use GetTouchingPart I found an interesting topic bypassing the Non-Collideable Issue here

See here for TouchInterest

local part = script.Parent

local function onPartTouched(otherpart) 
print(otherpart.Name)
end


part.Touched:Connect(onPartTouched)

This discussion is preserved as it was. New answers, comments, and votes are closed.