Your First Script

From Legacy Roblox Wiki
(Redirected from Your first script)
Jump to navigationJump to search

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.

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. This will be the setup used in most tutorials from now on.

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.

Inserting a New Script

The explorer pane.

Now that you have what you need, you'll create a new script. In the Explorer panel, click the Workspace icon (). This is so the script goes into the Workspace when you insert it.

Next, click Insert > Object.... When you do this, a window with a list of objects you can insert will pop up. Find the Script (), and click OK to insert it.

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!

Editing Your Script

Try clicking the Play button (). In the Output, you'll see Hello world! Where did that come from?! Well, it happened because of the script you inserted! Press the Reset button () to reset everything. If you can't see your script, click the expand button () 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 print() around the "Hello world!" is a function. Functions can be used to do certain things. In this case, the print function is used to say something in the Output.

Try replacing Hello world! with some text of your own. You can say anything you want! When you've done that, close the script editor by clicking the X (). Now press the Play button again. You should see your text appear in the Output. Congratulations! You've just made your first script!


See Also

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