Roblox scripting chronicles tutorial

This member has a Ph.D. (verified)

Find other posts in the same category: | | |

More details

The Scripting Chronicles - Part 1
Posted on July 16, 2008 by quint1997

I get probably 5 messages a week asking “can you help me with a script?” or “dude I need like one line of script, help!” My reply is usually “Go read the wiki!” But I now realise that some people need a little more help, so I’ve decided to do a little artice about scripting.
Basic Scripting - Part 1

Before we start, we first have to memorise some code. These pieces of code are used in almost every script.


What to remember:

function- what the script does

if- This tells a script to do something under a certain condition.

end- This ends a function or another piece of code

else- Tells a script to do someting if the conditions under “if” are false

print- prints something in the output window


Now let’s start! First, open up Roblox studio. Click on insert>object>script and erase print(”hello world!”). Then make a door and a button. Group them together and insert the empty script in the button. Follow the instructions below.

The Script

We are going to make a basic touch door!

The first line is below:

function onTouched(hit)

The above tells the script what the function is when it is touched.

script.Parent.Parent.Door.Transparency = 1

The above tells the script that is parent’s (the button) parent (the door) will turn invisible

script.Parent.Parent.Door.CanCollide = false

The above line will let some one go right through the door


This ends the function.


The script performs this for 3 seconds before moving on to the next lines.

script.Parent.Parent.Door.Transparency= 0
script.Parent.Parent.Door.CanCollide= true

The above makes the door become visible and solid again.


ends the function


This is the last line to the script. This connects the script to the button.

And we are done! Try to type the script from memory before you copy in the following lines. This will help you in the future.

function onTouched(hit)
script.Parent.Parent.Door.Transparency= 1
script.Parent.Parent.Door.CanCollide= false
script.Parent.Parent.Door.Transparency= 0
script.Parent.Parent.Door.CanCollide= true

Coming soon- Basic scripting part 2

To see articles on the same topic, click the links below the name of the author at the top of this page.