What does Event:Once() do?

I’ve recently noticed the new function :Once() for all events and I was wondering what it does. For example, brick.Touched:Once(), folder.Changed:Once(). Thanks.

9 Likes

It connects a function that is disconnected right after it’s fired, hence why it’s called once.

It can be used for functions that are only going to be used once so you don’t have to manually disconnect them.

Example code:

Part.Touched:Once(function(hit)
	-- Won't fire again
	print(hit.Name)
end)
49 Likes

Ohhh nice, whole time with my game’s weapons, I’ve been using the magnitude between the weapon and taget’s torso when I can use touched.once!!!

5 Likes