🛠️ HANDLING DEBUGGING in Roblox Lua

Debugging = finding and fixing errors in your script when it’s not doing what you expect.


🧠 DEBUGGING


🟢 1. Check if your code runs at all

lua
CopyEdit
print("Script started")

If this doesn’t show up in the Output window, your script might not be running at all.


🔴 2. Typo in object name

lua
CopyEdit
local part = game.Workspace.MyPart

🔻 If there is no part called MyPart, you’ll get:

pgsql
CopyEdit
Workspace.Script:1: attempt to index nil with 'MyPart'

✅ Fix it:

lua
CopyEdit
local part = game.Workspace:FindFirstChild("MyPart")
print(part)  -- check if it's nil


⚠️ 3. Accessing a child that doesn't exist

lua
CopyEdit
local light = script.Parent.SpotLight