Event (Lua)

An Event in Roblox Lua, is when something occurs in-experience. This may be a part being touched, or a Player respawning. Events can be connected to a function, and this function will run when the event is called. Some events also come with arguments, that can be used.

Events are represented as RBXScriptSignals. When an event's :Connect method is called, it creates a connection and returns a RBXScriptConnection, allowing this connection to be disconnected.

Examples
This example is an example of a being touched. In this example, a part is being created. When it is touched, it prints the name of the touching part. 'hit' is an argument provided, which is the part touching the created part.

But what is the 'connection' variable? 'connection' is a RBXScriptConnection. An RBXScriptConnection is an object returned by the :Connect function of an event.