Event-Style Functions: Coding lesson for kids
In “Event-Style Functions”, children learn about function onTouch(part) print("Touched!") end and part.Touched:Connect(onTouch).
function onTouch(part) print("Touched!") end: Defines a function — but by itself, defining it does NOT make it run. It just creates the function and waits.
part.Touched:Connect(onTouch): This is what actually wires the function to the event. Without :Connect(), naming a function "onTouch" does nothing special.
This lesson is part of Lua in Coding at Pearls Valley Academy — The language behind Roblox’s Luau.
Each lesson starts with a short narrated, animated explanation, then hands-on practice. A wrong answer gets a gentle hint, never a penalty, and children earn stars and pearls as they go.