I cant use any oth those cause touch interest dont always get the person if the block is anchored and cancollide = false and cant use :gettouchingpartsa cause i want the part to becancollide = false
Is There Any Other Touch Method Instead of TouchInsterest Or :GetTouchingParts?
1 answer
You could listen for the Touch and TouchEnded events, adding each part added to a weak-keyed dictionary (so that it won't keep Destroyed parts in memory), like so:
local part = script.Parent
local parts = setmetatable({}, {__mode="k"})
part.Touched:Connect(function(p)
parts[p] = true
end)
part.TouchEnded:Connect(function(p)
parts[p] = nil
end)
I sometimes find that TouchEnded won't fire properly, which means you should improve the script to automatically remove a part from parts if it moves some distance away.
4 comments
it worked but when ever i shoot the kamehameha it starts lagging... I know its touch interest. know any fix?
Use table.remove, making a key nil does not remove it from the table.
you can't use table.remove for a key inside a dictionary. This is correct.
I don't get why you used a metatable, and overall this method seems extremely pointless to me in most situations.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
.Touched
It's probably overkill, but you could also make a Region3 slightly larger than the part (as long as it's axis-aligned), and use GetPartsInRegion3 to find the parts touching it. There are much better ways, depending on your specific situation.
can u show me cause last time i used region3 i could not get it right and it was glitchy