Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i do a simple variable?

Asked by 10 years ago

How do i do a variable?

3 answers

Log in to vote
2
Answered by 10 years ago

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!

1
Thanks for helping me! iluvmaths1123 198 — 10y
1
Accepted! iluvmaths1123 198 — 10y
0
Thanks mate :) iluvmaths1123 198 — 10y
0
There's a 1+ for ya too iluvmaths1123 198 — 10y
View all comments (3 more)
0
The only problem is with the string variable.When you do it it will print nil in the output iluvmaths1123 198 — 10y
0
Well, you can do print('Text') Grenaderade 525 — 10y
0
Thanks! iluvmaths1123 198 — 10y
Ad
Log in to vote
1
Answered by
Dominical 215 Moderation Voter
10 years ago
MyVariable = 20 -- You can put any data here. Like, numbers, strings, etc
0
Thanks!But can the text myvariable allowed to be changed into any name you want your variables name to be? iluvmaths1123 198 — 10y
0
Yes, any legal name in lua can be defined like this. All letters and underscores, and a number after the first character. User#2 0 — 10y
0
Cool! iluvmaths1123 198 — 10y
Log in to vote
0
Answered by 10 years ago

You can use variables for short cuts.

Part = game.Workspace.Part

You can name your own brick with a variable.

Hi = game.Workspace.Part
0
So do you mean part is going to be the variables name or is hi the variables name?But still thanks for helping me! iluvmaths1123 198 — 10y
0
Part is a shortcut, Hi is naming. And no problem. Roboy5857 20 — 10y

Answer this question