User:SoulStealer9875/How to Script

From Legacy Roblox Wiki
Revision as of 17:18, 28 April 2012 by >SoulStealer9875 (Created page with "''Ever wanted to learn how to script but don't know where to begin? This guide is for you. We will begin small, and gradually progress to higher levels of scripting. If you al...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Ever wanted to learn how to script but don't know where to begin? This guide is for you. We will begin small, and gradually progress to higher levels of scripting. If you already have a basic understanding of scripting, you can skip it.

This is still being written, please understand that if something doesn't make sense, it doesn't mean it is going to still not make any sense in the stable version when this is finished.

If you have any ideas for this, you may write on the discussion page or send me a PM.

Introduction

In this first page we will learn the basics, such as Print and variables.

Setting up

First, create a script. Make sure you are in Roblox Studio, if you haven't already done so, or if it is not yet open, go to View -> Explorer and then View -> Properties.

We will be working with the Explorer and Properties panes now.

We will also be working with the Output pane, go to View -> Output to open it.

Go to Insert -> Object -> Script, in the Explorer pane you will notice that under Workspace is a new object, "Script". Double click on this to go into the script editor.

Print

Main article

The Print method is commonly used for debugging broken code that doesn't receive any output. We will learn about output later on. First create a script if you haven't already done so.

Double click on the script in the Explorer pane to go into the script editor. The first thing you will notice is that it says print 'Hello World!'. This is the default script when pulling one out of the Objects menu like we did earlier to create this one.


Close the script editor by clicking the little "x" to the left of the Explorer pane. Now to test this script, press the green play button located in Roblox Studio. I will not give you direct locations to items in Roblox Studio, as you should be familiar with this before starting the road to scripting. If you don't know where everything is in Studio then I suggest you don't learn scripting until you learn about the Studio Environment.


Did you notice that? When you pressed the play button, the output talked to us! The output said Hello World!. Why is this you wander? Because the default code in the script we created said print 'Hello World!' That's right! Anything between the quotes is printed in the output window.


Okay, now click the pink reset button by the play button in Studio and open up the script again. Let's have a play around. Try changing the text between the quotes and clicking play to see what it says now.

When you memorize the script, and when you're done playing. You'll be happy to know there are different ways of doing this. Like these:

Example
print('Hello World!')
print("Hello World!")
print[[Hello World!]]
print "Hello World!"


Interesting right?

Also it doesn't have to be just one, you can print more than one thing using this method, check this out:

print("Hello", "World", "!")

Prints exactly the same, Hello World !.

Keep messing around with it, and see what you discover.


Unfinished!
This guide is unfinished, please check back later!