You built an obby, so you’ve felt the magic of Touched events already. This lesson makes the pattern crisp so you can reuse it on purpose everywhere. An event is something that happens in the game: a part gets touched, a button gets clicked, a player joins. Your job is to listen for it and run a function when it fires.
The shape is always the same. You write a function, then you connect it to the event:
local part = script.Parent
local function onTouch(otherPart)
part.Color = Color3.fromRGB(0, 255, 0)
end
part.Touched:Connect(onTouch)
Read that bottom line slowly, because it’s the heart of all event code. part.Touched is the event. :Connect() says “when this happens, run the function I’m handing you.” Notice you pass onTouch without the parentheses, because you’re handing over the recipe, not calling it yourself. Roblox calls it for you, later, every time the part is touched.
That otherPart parameter is a gift: Roblox tells your function exactly what touched the part. Soon you’ll use it to check if it was a player and not just a falling brick.
Work the checklist, then walk into your part and watch it light up. When it reacts to your touch, mark it done.