Common errors in scripting, knowing them and fixing them

Common errors in scripting, finding, knowing them and fixing them.

Did you any time have issues with your code? Having a error that brought you to your nerves? Or something similar to so? Well, then this tutorial might a useful resource for you!

Finding them.

Finding them is rather easy to do. Roblox Studio has an window called ‘Output’, which can be opened by toggling it from the View tab, found on the upwards section of Roblox Studio’s screen:

Now, what’s the Output for? Well, as it says by it’s name, it will output results given from LuaSourceContainers.

These results can be multiple things. They can be errors, printed messages, warned messages etc.
And yes, of course, between them, errors is included.

Knowing them.

Knowing the root of the issue is very important. There are several errors you can possibly get. And to know them, you’ll carefully read the error, and think what is it which happened.

Errors can be well described, or not. But it’s rather down to your knowledge. And lazyness.

But, here are few common errors:

Test Subject One

Code:

local Part = workspace['TestSubject1']

Expected result:
TestSubject1 is not a valid member of Workspace "Workspace"

Oh, huh, you might be wondering, why did it say that? Well, that was caused because TestSubject1 isn’t an child, nor an property of workspace. And so, it gave a error. This error was a indexing error, since we tried to index something which was nil.

Test Subject Two

Code:

local TestDictionary = {Yes = 'y e s', RUSerius = 'no'} 
TestDictionary:Destroy()

Expected error:
local TestDictionary = {Yes = 'y e s', RUSerius = 'no'} TestDictionary:Destroy():1: attempt to call a nil value

Oh- What is which happened? Which value was nil? Well, to answer that question, we, as told earlier, read carefully.

You’ve done it? Hopefully yes, otherwise - this happened because we tried to call an function, but that function wasn’t part of it, and yes, the error says attempt to call, which means we already can recognize that it was a error thrown by trying to call something. And once again, this was a indexing error.

Other common issues / errors are assigning errors, where you try to set the value of something, to something else. And it can come in many forms (Just like indexing errors), such as trying to set something which is not compatible with what it is. A example would be where you’d try to set the .Size property of an BasePart, to an string.

Fixing them.

Both Test Subjects can be fixed by simply using:

Test Subject One. An existing part, which is accessible.
Test Subject Two. An existing function, which I would rather believe that it’s impossible, because there aren’t any available functions for tables. (The table global dictionary is something else. And you can’t destroy an table, unless you get rid of it, by setting it to nil; if possible.)

And assigning issues, well, could be fixed by assigning a compatible value. Or what the error suggests.

Sorry if the post seems to, or even, IS, not enough to be placed on #resources:community-tutorials, I’m trying (hopefully) my best so they don’t get stuck or spend extra time on something, if you have any concerns, leave a reply, or PM me, don’t straight flag it, please.

8 Likes

Thanks for this, Imma read into it seems very helpful as I’m newer to scripting and debugging is a very tedious job.