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

Is There Any Other Touch Method Instead of TouchInsterest Or :GetTouchingParts?

Asked by 6 years ago

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

0
.Touched hiimgoodpack 2009 — 6y
0
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. nicemike40 486 — 6y
0
can u show me cause last time i used region3 i could not get it right and it was glitchy DarkerThanBlack20 -11 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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.

0
it worked but when ever i shoot the kamehameha it starts lagging... I know its touch interest. know any fix? DarkerThanBlack20 -11 — 6y
1
Use table.remove, making a key nil does not remove it from the table. hiimgoodpack 2009 — 6y
1
you can't use table.remove for a key inside a dictionary. This is correct. CootKitty 311 — 6y
0
I don't get why you used a metatable, and overall this method seems extremely pointless to me in most situations. CootKitty 311 — 6y
Ad

Answer this question