generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: LUA SCRIPTING TUTORIAL | part 1

Previous Thread :: Next Thread 
DashTechBeat is not online. DashTechBeat
Joined: 28 May 2011
Total Posts: 8214
24 Jul 2014 12:35 AM
Your very first step to becoming a scripter is HERE.

part 1

VARIABLES |
First, you must know how to make a variable. Variables can define many things such as, defining a brick, defining the game, defining a boolvalue, and many other good stuff.
To start, heres an example
Brick = game.Workspace.Part
You must have a Part in workspace in order for this to work.
The "Brick" variable is now defining the part in the game's workspace.
Variables can also be like:
BaseNumber = 5
BaseText = "Hello!"
They don't have to be Brick, BaseNumber, and Text, in fact: you can make ANY name for a variable you want!

CHANGING BRICKS TRANSPARENCY, COLOR, AND OTHER STUFF |
Now, you must know how to change a brick's settings.
Here is a example with variables used:

Brick = game.Workspace.Part
Brick.BrickColor = BrickColor.new("Bright red")
Brick.Transparency = 0.5
Brick.Reflectance = 0.3
Brick.Name = "Part"

You can set the numbers/text to anything you want.
Text always needs quotes, unless you have the quoted text in a variable.

Now, here's an example WITHOUT variables:

game.Workspace.Part.BrickColor = BrickColor.new("Bright red")
game.Workspace.Part.Transparency = 0.5
game.Workspace.Part.Reflectance = 0.3
game.Workspace.Part.Name = "Part"

You can set the numbers/text to anything you want.
Text always needs quotes, unless you have the quoted text in a variable.

TRUE OR FALSE? |
You can use "true" and "false" for lots of things, mostly used as bools and other stuff.

Answer = true
Answer2 = false

You can use these for many things. There will be examples of this shown in either my other parts of my lua scripting tutorial, or here.

WAITING |
You can use wait() for many things. You can do wait(1), wait(2) and so on.
Here is an example:

Variable = 5
wait(1)
Variable = 4
wait(1)
Variable = 3
wait(1)
Variable = 2
wait(1)
Variable = 1

You can change the numbers around if you want to.

IF STATEMENTS |
"if" is used for many things, such as checking things and other good stuff.
= is used for assigning variables
== is used for checking & comparing variables.
Let's begin with a great example:

Variable = 6
if Variable == 6 then
Variable = 5
end

That was a VERY basic example.
We will be using the "else" piece now, which will trigger an action if its not whatever number or text.

Variable = 6
if Variable == 6 then
Variable = 5
else
Variable = 6
end

That was another basic example, but not as basic as the other one.
NOW we will use elseif:

Variable = 6
if Variable == 6 then
Variable = 5
elseif Variable == 5 then
Variable = 6
elseif Variable == 4 then
Variable = 6
elseif Variable == 3 then
Variable = 6
end

Moving on.

WHILE LOOPS |
You can use while loops for anything. This will repeat itself.

Variable = 6
I will be showing you multiple examples:

while Variable == 6 do
wait(.1)
Print("Hi!")
end

while true do
wait(.1) --required or you will crash
Print("Hi!")

while wait() do --you can set the number in wait() if you want
wait(.1)
Print("Hi!")
end

while wait(.1) do --an example of what I said above
Print("Hi!")
end

END |
Well, that's it for Part 1!
I hope this helped! :)
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
24 Jul 2014 12:36 AM
i dont under stan wut is a rblx/
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
24 Jul 2014 12:37 AM
above is rite, vry much to complicated. plz define.

this is a signature: pcall(function() print([[apparently this is a string]]) end)
Report Abuse
notlisted is not online. notlisted
Joined: 22 Jul 2014
Total Posts: 132
24 Jul 2014 12:37 AM
While this was well made, and could be very useful for beginners, it really shouldn't be posted here. It would have been better if you had just created a ROBLOX wiki page.
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
24 Jul 2014 12:39 AM
notlisted, I disagree, this is the right place for begineers.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Jul 2014 12:41 AM
This doesn't go deep enough
Report Abuse
notlisted is not online. notlisted
Joined: 22 Jul 2014
Total Posts: 132
24 Jul 2014 12:42 AM
Actually it's not,it shouldn't be here, because this forum is for helping people with broken scripts, not recreating a tutorial which has been made before.
Beginners should go HERE:

http://wiki.roblox.com/index.php?title=Cookbook
http://wiki.roblox.com/index.php?title=Category:Scripting_Tutorials
http://wiki.roblox.com/index.php?title=Basic_Scripting
http://wiki.roblox.com/index.php?title=Absolute_beginner%27s_guide_to_scripting
https://www.youtube.com/watch?v=_9aGRXxiezE
https://www.youtube.com/watch?v=Urvn69ZbM_Y


Report Abuse
DashTechBeat is not online. DashTechBeat
Joined: 28 May 2011
Total Posts: 8214
24 Jul 2014 12:42 AM
@Cnt
I'm trying to keep it shorter so people don't go like
"oh my god tl;dr this sucks no one would read it"
Report Abuse
notlisted is not online. notlisted
Joined: 22 Jul 2014
Total Posts: 132
24 Jul 2014 12:43 AM
I honestly doubt anybody who's willing to learn Lua would 'tl:dr' a tutorial for it.
Report Abuse
DashTechBeat is not online. DashTechBeat
Joined: 28 May 2011
Total Posts: 8214
24 Jul 2014 12:45 AM
I wish I could post this on ROBLOX wiki. I'm a really great scripter, even though the fact I've only scripted for a few months, I feel proud of myself.
Ever since I learned how to script I've been a successful game developer.
Report Abuse
notlisted is not online. notlisted
Joined: 22 Jul 2014
Total Posts: 132
24 Jul 2014 12:45 AM
http://www.wikia.com/Special:CreateNewWiki
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Jul 2014 12:46 AM
Deep in understanding, not in quality.

Lua Scripting Tutorial - Part 1: Variables and Datatypes
Lua Scripting Tutorial - Part 2: Scopes
Lua Scripting Tutorial - Part 3: Predefined variables (print, table, string, tostring, tonumber, ...)
Lua Scripting Tutorial - Part 4: Indexing through the DataModel hierarchy.

IDK
Report Abuse
DashTechBeat is not online. DashTechBeat
Joined: 28 May 2011
Total Posts: 8214
24 Jul 2014 12:47 AM
@Cnt
this is the beginners tutorial.
Scopes, predefined variables, indexing through datamodel stuff is all advanced and I'll get to that in the advanced parts of the tutorial.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Jul 2014 12:48 AM
predefined variables aren't advanced, they're just like print.
and you already indexed through datamodel:

Game.Workspace.blub
Report Abuse
DashTechBeat is not online. DashTechBeat
Joined: 28 May 2011
Total Posts: 8214
24 Jul 2014 12:49 AM
Oh, the way it sounded, actually sounded advanced to me.
I'm sorry about that.
Report Abuse
DashTechBeat is not online. DashTechBeat
Joined: 28 May 2011
Total Posts: 8214
24 Jul 2014 12:53 AM
Bump.
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
24 Jul 2014 12:54 AM
>Is on first page late at night when like no one is posting
>bumps
yes
logic -->window
Report Abuse
DashTechBeat is not online. DashTechBeat
Joined: 28 May 2011
Total Posts: 8214
24 Jul 2014 02:34 PM
Bump 2.
Report Abuse
IBuildOn is not online. IBuildOn
Joined: 20 Oct 2012
Total Posts: 4885
24 Jul 2014 02:43 PM
@Dash
It is impressive you use your time to help others learn Lua. If people don't understand, they shouldn't hate you because they don't see how you tried to help them. And, I just learnt While loops because you mentioned it in the middle of the tutorial.

Here is a tip though: Instead of writing tutorials, make videos, so people can understand better.

{~Toronto is my home. Apples are my favorite~}
Report Abuse
IBuildOn is not online. IBuildOn
Joined: 20 Oct 2012
Total Posts: 4885
24 Jul 2014 02:44 PM
@128GB

It isn't late at night, well at least for dash and me, for us it is 4 PM. People play ROBLOX in other countries.

{~Toronto is my home. Apples are my favorite~}
Report Abuse
VerifiedName is not online. VerifiedName
Joined: 26 Jul 2009
Total Posts: 4534
24 Jul 2014 02:45 PM
"in fact: you can make ANY name for a variable you want!"

pretty sure you can't.

Report Abuse
IBuildOn is not online. IBuildOn
Joined: 20 Oct 2012
Total Posts: 4885
24 Jul 2014 02:48 PM
@Verified
Learn Lua, yes you can make any name for variables. Unless it has a space in it.

{~Toronto is my home. Apples are my favorite~}
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
24 Jul 2014 02:48 PM
You cannot use any name you want for a variable.
STOP SPREADING FALSE INFO
Report Abuse
VerifiedName is not online. VerifiedName
Joined: 26 Jul 2009
Total Posts: 4534
24 Jul 2014 02:54 PM
"Learn Lua, yes you can make any name for variables. Unless it has a space in it."

alrighty then,


local if = 'x';

print(if); ---> 20:52:32.746 - Error in script: '(name)' expected near 'if'



so before you tell me to learn lua, learn it yourself.

Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Jul 2014 02:54 PM
You can make any variable name you want, and you can even use other datatypes as the key.

Although the way I'm mentioning requires it to be a global variable since roblox removed the debug library.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image