Your First Script

(Redirected from Your first script)

[edit] Introduction

This tutorial is for complete beginners in scripting. You will use this tutorial to learn how to create a simple script from which you can build scripting knowledge.


[edit] Setup

It is important to get to know the environment you will be working in. If you haven't already, read through the Roblox Studio article to become more familiar with the Roblox Studio.

Open up Roblox Studio. Make sure you have the Standard Studio View setup. Once you have the studio setup, create a new place to work in. You'll need an open place in order to create new scripts and run them.

[edit] Inserting a New Script

The explorer pane.

Now that you have what you need, you'll create a new script. First, select the tab labeled 'view' and open the Explorer panel. In the Explorer panel, click the Workspace icon (Workspace icon.png). With this icon selected, the script will now go into the Workspace when you insert it.

Next, select the 'Advanced Objects' icon under the 'Insert' tab. Find Script Script icon.png and double click it. Alternatively, use the 'Search Bar' to find the item you're looking for, in this case 'Script'.

In the Explorer panel, you should see a new script icon named "Script", under the Workspace. That means you've just inserted a script into the workspace!

[edit] Editing Your Script

Open the Output window under the 'view' tab. Now try clicking the 'Play Solo' button under the 'home' tab. In the Output, you'll see Hello world! Where did that come from?! Well, it happened because of the script you inserted! Also, notice that studio both creates a player for you to manipulate and runs your script. Press the 'Reset' button to reset everything. If you can't see your script, click the expand button (Expand.png) next to the Workspace to see its children (if you still don't see your script, try inserting another one).

Let's see how the script did that. Double-click on your script to open the script editor. A new tab will open with the name of your script, and a white space with some text will cover the game window. Notice that the text says
print("Hello world!")
That's where the text in the Output came from. The word print before the 'Hello World!' shows that we're using a function. We can use functions for certain tasks. In this case, the print function is used to "print" something to the Output.

Try replacing Hello world! with some text of your own. You can insert anything you want!

When you've done that, close the script editor by clicking the X (P01F15.png). Now press the 'Play Solo' button again. You should see your text appear in the Output. Congratulations! You've just made your first script!

[edit] See Also

If you're looking for something similar or closely related to this article, see these: