How do i do a variable?
How do i do a simple variable?
3 answers
Here's a variable with numbers:
AnyName = 31
With a number variable you can do this:
wait(anyname)
It will wait 31 seconds.
String variable:
AnyName = "Text"
With a string variable, you can do this:
print(anyname)
It will print 'Text' in the output
And last but not least, the Object variable:
AnyName = game.Workspace.Part --example
With an Object Variable you can do this:
AnyName.CFrame = CFrame.new(32, -299, 333)
Changes the Objects location
And:
AnyName:clone().Parent = Workspace
Copies the Object and puts it into Workspace, but without '.Parent = Workspace' it will become nil
And there is a lot of other uses for variables, I hope this helped!
MyVariable = 20 -- You can put any data here. Like, numbers, strings, etc
3 comments
Thanks!But can the text myvariable allowed to be changed into any name you want your variables name to be?
Yes, any legal name in lua can be defined like this. All letters and underscores, and a number after the first character.
Cool!
You can use variables for short cuts.
Part = game.Workspace.Part
You can name your own brick with a variable.
Hi = game.Workspace.Part
2 comments
So do you mean part is going to be the variables name or is hi the variables name?But still thanks for helping me!
Part is a shortcut, Hi is naming. And no problem.
This discussion is preserved as it was. New answers, comments, and votes are closed.

7 comments
Thanks for helping me!
Accepted!
Thanks mate :)
There's a 1+ for ya too
The only problem is with the string variable.When you do it it will print nil in the output
Well, you can do print('Text')
Thanks!