⚡ COMMON ROBLOX EVENTS – Beginner Scripting Notes


📌 What are events?

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.


🧍‍♂️ 1. Touched

Runs 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:


🎮 2. UserInputService.InputBegan

Runs 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: