To make it more clear, I want to print the name of every part that's touching a part with a touch listener at the same time. Here is my code:
game.Workspace.Part.Touched:Connect(function(a) print(a.Name) game.Workspace.Part.CanTouch = false wait(0.5) game.Workspace.Part.CanTouch = true end)
This code prints out the same part over and over again. It could be because the touch listener only has 1 parameter to detect just 1 part. So must I detect collision another way to print out all of the colliding parts, like raycasting?
This might be of use to you. This returns a table of all touching parts which include all BaseParts that either have cancollide true OR cancollide false with a touchInterest.
Incase your afraid it won't get all the parts because of properties, just add a touch interest to the part you want to get touching parts from. Then you can stop the interest after getting touching parts, this way, you have all the possible touching parts and the touch interest is gone afterwards which is good for memory. Like this
Connection = Part.Touched:Connect(function()end) -- adds touch interest TouchingParts = Part:GetTouchingParts() -- sets variable to table of all touching parts Connection:Disconnect() -- rids the parts touch interest to save memory so it doesn't keep track of something that's not used.
I hope this helps :3