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

How to change a variable?

Asked by 2 years ago
Edited 2 years ago

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

0
You just changed the variable. NotThatFamouss 605 — 2y

2 answers

Log in to vote
0
Answered by
sngnn 274 Moderation Voter
2 years ago

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

Ad
Log in to vote
0
Answered by
Antelear 185
2 years ago
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

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. Antelear 185 — 2y

Answer this question