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

How can I turn a string value into a int value?

Simple question, how do I turn a string value into a int value. In Python, the programming languages I'm most comfortable with, you simple write:

strvalue = "3"

toadd = 7

strvalue = int(strvalue)

total = strvalue + toadd

But how can i do this in Lua

2 comments

0

There's a built-in called "tonumber" that will convert to a number type from a string type. For example; tonumber("5") --> 5

0

Just grab whats in the IntValue, then delete the invalue, then put everything in the IntValue into the number value :P

1 answer

✓ Accepted answer

int = tonumber(string)

3 comments

0

but what if the string is "2.33" for example, that wont be an integer

0

Thanks

0

Well, if it's 2.33 he will just have to make a numberValue instead, makes no difference + he asked how to turn a string into an integer, and there is simply no way to make "2.33" an int, considering that an int can't have decimals

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