How to declare variables with specific data type?

I want to create a number variable that is integer and not float, but when I declared the variable even if I didn’t give “.0” behind the number, it gave me float instead of integer. In C++, We can just write something like:

int var = 1;
float x = 1.00;
string p = "Ehee";

How do I do it in Lua?

You can just do:

local whatever = "whatever"

You do not need to define the type.
You may want to learn more on lua before diving straight onto the devforum.
https://www.lua.org/ is a good site to learn from.

While integers do exist in later versions of lua, there are not present in the version being used for Roblox.

For future reference go to google and type roblox wiki then whatever the subject is> roblox wiki variables > roblox wiki functions. You’ll find your answer relatively faster than just asking it here. Also the link for the wiki is always developer.roblox.com. Sometimes youll see roblox.fandom.com > which should be avoided.

Also this helps prevent questions that have been asked hundreds of times.

I didn’t? I never messaged you, but ok?

What? Messaged you on what? You’re telling me I said something without any proof its actually me? You’re very rude lmao

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)

ight i just figured out how to declare variables, just basically do this

local myNumber: number = 123

so first put local meaning its a local variable, then the variable name, next the variable type, such as if it was a string you put string and for number put number, and etc and lastly you put the variable value, it has to correspond to the variable type, if its a number you put a number such as 1234 and if its a string you put something like “Hello” other wise if you mix and match values it won’t work strings won’t go numbers and etc, you get what im saying

7 Likes

If you put it in a string or another non-number value, it will work when you actually run it, just that the script editor will yell at you for using the wrong type.