Scripting Lesson 007: Testing Your Scripts

Greetings everybody, Domswolf here. Congrats to all who got promoted to Dev Trainee, I'm glad I could help you get started on your long scripting journey. Today we will discuss testing your scripts. Now this may seem pretty simple: You just go in Play Mode and test it. It can be harder to do this because you may not know what is wrong with your script. So first, in this shorter lesson, let's learn how to test our scripts in a few different ways.

The first thing you want to do is go to your View tab and click Output. This shows everything that is going on in your scripts (well, it shows errors at least) For an example I just made a kill brick that has a mistake in it that needs fixing.

Output says...

Now if we take a look at the Output, it tells us what the error is and what line (In this case, line 2) the error is in. Now many people tell me "What does indexing a nil value mean?". This basically means that the humanoid hasn't been checked, so I just simply add if script.Parent.Parent:findFirstChild("Humanoid") ~=nil then and an extra end to fix the script.

Now we will learn what printing is. Printing is when you use a script to print something to the output. Here is an example:

Now you may notice that instead of writing the word LEL into the script, I did ("Lel"). This is what is known as a string literal, it is basically how you would write a word for a property that isn't a number value or a true or false (Boolean). To point out, it is not mandatory to use the print function anywhere in the script.

If anybody has any questions on what the output's message means, feel free to PM me. Thanks for tuning into this shorter lesson.

-Domswolf, edited by le Snapcash!