An Event in ROBLOX lua, is when something occurs in game. 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.


This example is an example of a ExplorerImageIndex 1Part being touched.

local part ="Part",workspace)
local connection = part.Touched:Connect(function(hit)
print("I've been touched by "..hit.Name)

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.