Object Events
From Legacy Roblox Wiki
You may be looking for Events
What are events? Events are basically saying 'when this happens, run this Lua code'. An event might include when an object is removed, when one part touches another part, etc, etc. Infact, a lot of code you use will be used to teach about events.