Despawned
|
  |
| Joined: 06 Apr 2013 |
| Total Posts: 12569 |
|
|
| 24 Mar 2016 11:07 PM |
I have seen that a lot of people seem to be having problems with variables. Most of these people are new to scripting, so I will go through it.
Variables are a way of shortening your code, and telling scripts to refer to a certain part in the studio. These can be models, unions, scripts, parts, tools, or really anything. You may have seen these before, here is what they look like, EXAMPLE:
Dog = game.Workspace.doghouse.dog
This is telling the script where to find the dog. First, it tells the script to go to the game, them workspace, then the model doghouse then dog.
Variables can also be able to shorten code. Say you wanted to refer to the dog again, you can just type "Dog" (case sensitive), instead of "Dog = game.Workspace.doghouse.dog"
I hope this helps some beginners out there, if you have any questions reply below. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 24 Mar 2016 11:19 PM |
sorry but that line of code was annoying me.
local dog = workspace.Doghouse.Dog |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2016 11:29 PM |
^
GavAttack12 // ClutchDeveloper |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2016 12:18 AM |
| I never really got the purpose of declaring a variable local if it's not in something like and if statement. Care to elaborate? |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2016 12:24 AM |
^ local variables process faster than global, barely, but still, you might as well.
|
|
|
| Report Abuse |
|
|
Neoryu
|
  |
| Joined: 04 Mar 2012 |
| Total Posts: 42 |
|
|
| 25 Mar 2016 01:07 AM |
| Where do you have proof of that? |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2016 02:23 AM |
The proof is in the source of Lua, it's open source.
A local variable lookup is a simple C-sided array lookup, a global variable lookup is a table lookup. |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2016 04:00 AM |
| I like how he spelled "beginners" wrong |
|
|
| Report Abuse |
|
|
Despawned
|
  |
| Joined: 06 Apr 2013 |
| Total Posts: 12569 |
|
|
| 25 Mar 2016 07:34 AM |
| I thought the "local" so I've been obvious, but yes. I should have included it. |
|
|
| Report Abuse |
|
|
Despawned
|
  |
| Joined: 06 Apr 2013 |
| Total Posts: 12569 |
|
|
| 25 Mar 2016 07:36 AM |
| This dang autocorrect makes me look like an idiot.. |
|
|
| Report Abuse |
|
|