Sunday, November 11, 2012

Mango's Tutorials: Beginning Scripting

Hey guys! I've asked some people and it appears that scripting is something that a lot of users are wanting to understand.

Beginning scripting is very easy to learn, if you have the urge and willpower to overcome the twist and turns that it's rocky road brings fourth. Once you've got the basics down, you'll be able to understand more complicated tutorials.

But before we get started, you'll need to have Roblox Studio set up properly. To do that, open Roblox Studio and start a new project.

Move your mouse over the "View" tab that's located on the top of your screen. your going to want to select "Explorer" and "Properties".

This is what the explorer should look like:


This is what the properties tab should look like:


Once you've got those tabs opened, we can continue on with the tutorial.

Notice when you click something on the explorer, you can change it in the properties tab. And everything that appears in the explorer, is in the game. Also take notice that everything is under "Workspace" in the explorer.

Alright, now I want you to insert a brick, and I want you to name it 'test'. The brick should appear as a "Part" in the explorer tab. Now insert a script. Do this by rolling your mouse over the "Insert" tab on the top of your screen, then click "Insert Object".



A window should come up, select "Script". A "Script" should be added to your explorer.

Double click the script. A window should come up with the text "Hello world" in it. Since we don't really need that there, your going to want to erase that.

What we're going to do, is change some of the properties of our 'test' brick using a script. In order to do that, we first have to tell the script what we want to edit. But, how do we do that? Simple.

First, we tell the script to look under 'game', since everything is in the game, obviously the brick is going to be in there. Then, if you look at the explorer, your going to want to identify it under 'Workspace' as well.

It should look something like this:

game.Workspace.test

First it looks in game, then Workspace and then it's directed to our brick, 'test'.

Now we want to change our brick.

Click the 'test' brick on the explorer and look at the properties tab. Let's change the transparency, to do that, we're going to show the script what we want to change. So add 'transparency' to the script, like so:

game.Workspace.test.Transparency

Now we can go ahead and change it. We want to add an '=' sign and put in the decimal you prefer, just like this:

game.Workspace.test.Transparency = 0.3

Congratulations! You've created your first script. Push the play button, if you've done everything correctly,  the 'test' brick should become transparent.

Send me a message HERE to ask me any questions!
Don't forget to comment!

No comments:

Post a Comment

Write your comment here... OR Flingi will eat you