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

How to change a variable?

I don't know if this is very simple or not but like how do u change a variable in a script

for example

lets say x is 30

x = 30

and i want to change it to 20

x = 20

how would i do that

1 comment

0

You just changed the variable.

2 answers

✓ Accepted answer

Well, you just did. Once you define a variable, you can change it via var = value.

local variable = "20" -- the two " are making it into a string. We will call it text to simplify it!
variable = 20 -- we then turn it into a NUMBER, and not TEXT.

when making a variable via local, you can easily change the value right after! Make sure to mark this answer if it helps you

1 comment

0

NOTE: in lua you must use locals for variables like 85% of the time, so if you are used to python you might want to change the way you think.

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