how to make a part turn off can collide when touching another part and return to can collide when untouch after 1 second?
COMMUNITY QUESTION
can someone answer the question below?
1 answer
If you're saying "Another part" I'll include any part including any human body. And I'll include a way so that it's not individual parts, but all parts
Technicially, there are two events (Touched, and TouchEnded)
You could use those two events to trigger that.
Let's say... the script is in the part. that'll bee...
local part = script.Parent
local buffer = {}
function doSomething(touchpart, touch)
if touch then
print("Touch...")
if not next(buffer) and part.CanCollide then
part.CanCollide = false
end
buffer[touchpart] = true
else
print("unTouch...")
buffer[touchpart] = nil
if not next(buffer) and not part.CanCollide then
wait(1)
part.CanCollide = true
end
end
end
part.Touched:connect(function(obj) doSomething(obj,true) end)
part.TouchEnded:connect(function(obj) doSomething(obj,false) end)
Let me know if this helps!
This discussion is preserved as it was. New answers, comments, and votes are closed.
