Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I use GetTouchingParts with a non CanCollide object?

Asked by
obcdino 113
6 years ago

Title says it all, my problem is using GetTouchingParts, but the object is non CanCollide Is there an alternate to GetTouchingParts, or is this just not possible?

1 answer

Log in to vote
1
Answered by
Avigant 2374 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

This is a bit of a hacky solution, but yes, it's possible.

Per the Wiki, if the part that is not collidable has a TouchInterest, it will count as touching as if it were collidable. So you could connect an empty function for this behavior. It's worth noting that you can't call Instance.new() to create a TouchInterest.

Assume we had two parts A and B in workspace, where B is inside A, and B is not collidable.

workspace.B.Touched:Connect(function() 
end) 

print(#workspace.A:GetTouchingParts()) --> 1

On the other hand, there may be better solutions to the actual problem you want solved, other than doing this.

http://wiki.roblox.com/index.php?title=API:Class/BasePart/GetTouchingParts

0
Thanks man! I don't understand why the API is even like that. obcdino 113 — 6y
Ad

Answer this question