Debugging = finding and fixing errors in your script when it’s not doing what you expect.
lua
CopyEdit
print("Script started")
If this doesn’t show up in the Output window, your script might not be running at all.
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
lua
CopyEdit
local light = script.Parent.SpotLight