Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i do a simple variable?

How do i do a variable?

3 answers

✓ Accepted answer

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!

7 comments

1

Thanks for helping me!

1

Accepted!

0

Thanks mate :)

0

There's a 1+ for ya too

0

The only problem is with the string variable.When you do it it will print nil in the output

0

Well, you can do print('Text')

0

Thanks!

MyVariable = 20 -- You can put any data here. Like, numbers, strings, etc

3 comments

0

Thanks!But can the text myvariable allowed to be changed into any name you want your variables name to be?

0

Yes, any legal name in lua can be defined like this. All letters and underscores, and a number after the first character.

0

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

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!

0

Part is a shortcut, Hi is naming. And no problem.

This discussion is preserved as it was. New answers, comments, and votes are closed.