Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

can someone answer the question below?

how to make a part turn off can collide when touching another part and return to can collide when untouch after 1 second?

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.