Roblox > Scripting Lessons >

Lesson 9: Built-In Functions

There are also a number of built in functions that allow you to do many things that could not be done without them. The first type of built in function is member functions. These functions are used on a specific object. Here is an example of how to use a member function.


You may have noticed that member functions are run just the same way as other functions but they are preceded by the object they are being used for then a colen :
Here is a list of some of the member functions and what they do.

Accepts no arguments. It returns a copy of the object it is used on.

Accepts the name of the child as an argument. Returns the child or nil if there is no child by that name. The advantage of using this function insted of just saying: ".name" is that it will not cause an error if the child does not exist.

Acceps no arguments. It returns all of the children of the object as a table. We will learn more about tables later.

Accepts no arguments. It removes the object from the game.

The other type of built in function is global functions. These are run just like normal functions. Here is an example:


Here is a list of the most important global functions. For a compleate list see:

Accepts a number as an argument. This function pauses the script for the specified time in seconds. So wait(60) would make the script pause for 60 seconds.

Accepts any number of arguments and prints them to the output window.

math.random(number1, number2)
Accepts two number arguments. It then returns a random number between the first number and the second number.

You may also wish to review the folowing wiki article. Some of it you might not understand, but don't worry. I don't understand all of it either. =)

If you have any questions PM me or Post on the Forums.

<- Previous Lesson  Next Lesson ->
Updated on Nov 13, 2010 by Ajedi32 (Version 9)
comments powered by Disqus