Events are like signals that say,
“Hey! Something just happened!”
Your code can listen for these and run a function when it happens.
You use .EventName:Connect(function() … end) to catch the event.
TouchedRuns when something touches a part.
lua
CopyEdit
local part = workspace.MyPart
part.Touched:Connect(function(hit)
print(hit.Name .. " touched the part!")
end)
✅ Used for:
UserInputService.InputBeganRuns when a player presses a key or clicks.
lua
CopyEdit
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Space then
print("You pressed SPACE!")
end
end)
✅ Used for: