Troubleshooting for Dummies


  • Troubleshooting for Dummies
    Difficulty Level: 1/5 Stars

    Hello everyone! I'm back once again to create another '[Insert Topic] for Dummies' tutorial! My previous tutorial,

    HttpService for Dummies

    received some hate :( but that's perfectly fine. I actually made a mistake in that tutorial when writing it (the url bit of code should be in quotations).

    Anyways, I've decided to bring troubleshooting up as a topic. New scripters always seem to have issues with errors that they get in the output, and not understanding what they mean or how to fix the error. That's perfectly fine, although it's important to learn. I realize some of you know that there's actually a Roblox Wiki tutorial on this (Lua Errors - Roblox Wiki), although I'm going to try to cover breaking down an error.

    Let's say you have this script:

    print("Hello World!) -- There's clearly an error there, I missed a quotation. I'm doing that on purpose ;)
    

    Here's how the output would look:

    16:31:05.176 - Workspace.Script:1: unfinished string near <eof>

    Now, let's break this up:

    '16:31:05.176' >>> This is actually the time of when the error occurred.
    '-' >>> Used to separate the time and the rest of the error.
    'Workspace.Script' >>> The location of the script in the explorer.
    ':' >>> Used to separate the line the error occurred on and the location of the script.
    '1' >>> The line inside the script that the error occurred on.
    ':' >>> Used to separate the line the error occurred on and the location of the script.
    'unfinished string near <eof>' >>> It's telling us that we started typing a string, although we forgot to put the end quotation. <eof> means 'end of file' so we know that the error happened towards the end of the script.

    Simple, right?
    Let's try something more complicated. Here's our script this time:

    local Table = {"Scripting Helpers is epic!", "I like troubleshooting scripts!")
    for index, thingInTable in pairs(Table do
    	print(index)
    	print(thingInTable)
    end
    

    I think you probably already spotted the error ;). But if you didn't that's perfectly fine! We'll just troubleshoot and find the error!

    Here's our error message:

    16:37:34.321 - Workspace.Script:1: '}' expected near ')'

    Let's break this up again. This is the last time we'll break it up!
    '16:37:34.321' >>> This is actually the time of when the error occurred.
    '-' >>> Used to separate the time and the rest of the error.
    'Workspace.Script' >>> The location of the script in the explorer.
    ':' >>> Used to separate the line the error occurred on and the location of the script.
    '1' >>> The line inside the script that the error occurred on. So, now we know that the error's on line 1!
    ':' >>> Used to separate the line the error occurred on and the location of the script.
    '} expected near )' >>> Seems like lua was expecting a closed curly bracket near the closed parenthesis on line one.

    Alright, so let's go ahead and revise line one of our script:

    local Table = {"Scripting Helpers is epic!", "I like troubleshooting scripts!") -- Look there, we used a closed parenthesis instead of a closed curly bracket! That error helped so much! :D 
    

    Now our fixed script:

    local Table = {"Scripting Helpers is epic!", "I like troubleshooting scripts!"} -- Curly bracket is there now :)
    for index, thingInTable in pairs(Table do
    	print(index)
    	print(thingInTable)
    end
    

    Now, let's run the game again and see if it works!
    Oh no! It seems we made another mistake! Look at this error:

    16:41:55.417 - Workspace.Script:2: ')' expected near 'do'

    Hmm.. Well, it looks like on line 2 lua was expecting us to put a parenthesis near do. Let's revise our code.

    local Table = {"Scripting Helpers is epic!", "I like troubleshooting scripts!"}
    for index, thingInTable in pairs(Table do -- Look, we missed a closed parenthesis here! Just like the error said: ") expected near do"
    	print(index)
    	print(thingInTable)
    end
    

    Okay, so here's our fixed script:

    local Table = {"Scripting Helpers is epic!", "I like troubleshooting scripts!"}
    for index, thingInTable in pairs(Table) do -- The closed parenthesis is there now! :D
    	print(index)
    	print(thingInTable)
    end
    

    Let's run the game one more time and...
    here's our output:
    1
    Scripting helpers is epic!
    2
    I like troubleshooting scripts!

    Everything worked! Fantastic! So, as you go along troubleshooting scripts you'll see new errors pop up that you've probably never seen before. If you ever have a question about an error don't hesitate to post a question here on Scripting Helpers.

    I'll leave this one for you to figure out:

    print("Have you figured this script out yet? Status: " .. false)
    

    Error:
    16:46:47.017 - Workspace.Script:1: attempt to concatenate a boolean value

    Hope I helped you! Enjoy your new ability to understand errors and fix your scripts :D


  • @mccrafter1212 Nice way to explain it! Something you should explain if the error says Error occurred, no output from Lua., it is probably a script trying to edit a value or see a value without the current permissions, like for example, you can't set FilteringEnabled with a regular script.


  • Good tutorial! I should write something like this :stuck_out_tongue:

Looks like your connection to Scripting Helpers was lost, please wait while we try to reconnect.