You are not logged in. Please log in if you wish to participate in all discussions on the website, chat with friends, and use everything we've got to offer.

Click Register below to, well, register. Derp. Enjoy your stay. ;)

If you do not have an account and wish to create one, please follow the link below.

http://www.robloxtoday.net/register

You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

Gravyerd


Telamon
If mods can, make this fixed (because is a tutorial)
This is my first tutorial on roblox, but I know a lot about global variables and can all help to improve this technique
Let's go:

1. Making the Variable - How to make a normal variable a global variable.
2. Making the Variable - How to make a global variable exists.
3. Manipulating the variable - How to change the variable
4. Showing the variable - Print,model's name and messages
5. Where use the global variable - Using the variable
No understand? go to the end of the Tutorial and see where you can find my Model's that will help you!!

1. How to turn a normal variable a global variable.


You've seen the prefix variables with local or even without prefix
ex:

and to transform this into a global variable is very simple

in this case the global variable is called halistik but you can change "halistik" to any name without space

2. How to make a global variable exists.

Create a new script in workspace and remove the text "", put in the first line =
and in the second line write "print(halistik)" <
in the top of the screen go to View>Output and exit script editor and copy the script, delete the script and paste the script and the script will active-self if the game is playing (if the time is not stoped)
see the output, he will say number ^^
you have a global variable, my global variable is "var1" (i put: _G.var1 = 0 )
and you already can use in others scripts

3. How to change the variable.
let's be direct:
the action to modify a variable is:
Code:
_G.var1 = _G.var1 + 1

It works like this: if X = 3, set X = (X+1) = X+1
you too can use
Code:
_G.var1 = 2
but this will not increase, if Var1 = 10, this script make he 2, and if var1 is 493653, this script will change to exact 2

I have a perfect script (and full)
Code:
function chng()
_G.var1 = _G.var1 + 1
print ("Var 1 = " .._G.var1.. "")
end

script.Parent.ClickDetector.MouseClick:connect(chng)

i know that "chng" is new, but i only write fast script , this script makes: when he click, var1 set to var1+1 (increase 1) and print Var1 = (G_var1) (if var1 = 2 he print "Var1 1 = 2"

4. Print,model's name and messages.

You already know how to print...
Need only know how to send a message, this can be learned even in the roblox wiki
put in the message space (after " = "message"")
Code:
"The Var1 is " .._G.var1.. " after var here "

it make the message to (without Quotes) "The Var1 is (numberhere) after var here "

Floating Text:
First make a model, a humanoid inside and a brick called "Head" inside, now you create a floating text that do not change.
My Exemple:
Add the script and put inside the script:
Code:
while true do --when 1+1 = 1 do (lol)
script.Parent.Parent.Name = "The Var1 is " .._G.var1.. -- set the model's name
wait(.05)
end

the wait is for no cause much lag (every 0.05 seconds the script change the floating text. [and the name of the model{o.O how :suspect: }.])

5. Using the variable

Any problem with your creativity? Wwhy are reading this? You do not have ideas for using variables?
ok ok... no brain working right?
Imagine Next Gem Tycoons: You buy anything and the price of the brick increase (OMG AND YOU KNOW HOW MUCH YOU WIN EVERY ONE!) or you can use to speed of rollercoaster, creation of maps (yes... any engines exist , hard to find), you can use
you can use to tycoons to change the price of brick. (a person paid 10 cash to gain +2 each brick.)
You can also use to change the speed of roller coaster or creation of maps (yes, maps), there are engines to create maps that allow script in roblox (not easy to find) , usefull, control blocks place ;/

you can use global variables to a lot of stuff is hard to think about things with numbers ...
use your creativity, you can make many maps cool! You remember those tools that rotate a object? Press A to increase the moviment, S to decrease ^^ each click adds 0.1 in the rotation number (2 point of rotation = 180)

see? variables may be more interesting than you imagine!

Credits:
All credits for me, Gravyerd, that created images and this script...
some parts I used my logic and other I had to remember what I learned in wiki.roblox.com
This tutorial Helped you? add me a friend and if you have a question, send message to my in roblox or here, i will see if i can help you ^^ good luck ^^

what the problem? do not understand X + Y? (X + Y = nothing)
Search by "Gravyerd"
You can use the my model , that will help you on GLOBAL VARIABLES!

acess http://www.roblox.com/Item.aspx?ID=9251458 to the four models
you too can try find it in Catalog ^^ Have Fun!



Last edited by Gravyerd on 4/1/2009, 5:27 pm; edited 2 times in total

View user profile

Alex


Special
Special
If you would like to ask questions. Please ask Gravyerd in the form of Private Messaging.


____________________________
Evening, Guest Welcome to the Roblox Today Forums!
Hello, I am Alex. The Forum's Head Moderator.



I joined ROBLOX, December 29th, 2007!
I was one of the first to join this lovely forum, invited by Clayton himself. The memories. Ah.
Administrators have too much power, therefore my position suits me just fine!
View user profile http://www.robloxtoday.com

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum