Variables - their purpose is to store data inside a script. 🗃️
They consist of a name and a value. 🤔
Their name is used to ACCESS the variable (read or write) and their value can be a number, string, boolean or even a table. I'll go over all the types later 👇
The name of a variable can contain any alphanumerical characters, but must NOT START with a number! 🔢
It can also include an underscore ➖
As covered above, a variable's value can be of any type - a string or number, a table or function and even an Instance like a part or a button! 👍
Here are all all the common types 👇
Number, 🔢
String - a sequence of letters 🔤
Table - a list of indexes and values 1️⃣🅰️
Function, 📞
Boolean - true or false ✅❌
Instance - any in-game object 🌲
Nil ⚪
What are local variables? 🔴
Local variables are used to not fill up the Global Namespace with unnecessary garbage 🗑️
But to understand that, we first need to know what Global Namespace means 👇
You cannot have two variables with the same name. If you try to declare a variable that already exists, it'll simply overwrite the previous one. ❌
But what about functions and loops?
👇
When you declare a LOCAL variable inside a function/loop, that variable is not accessible outside of the function, only inside it. 🤔
I am going to make a thread about scope/namespace in the future, but for now, this is the end.
Tomorrow's thread is going to be about TABLES, so if you want to learn more, follow @notactulurus! 🌟
👇❗
Also, we're trying to surpass @AntcarTweets in followers by the end of this month. He's offered to give me 300 R$ if we do, so all that Robux is going to my LAST FOLLOWER! 💵