I am making a system that can have a number string that I can do math (+1) with and I want it to be changed into a text string so I can put it on a GUI. Is there a certain method or can I do math with a Text String?
✓ ANSWER ACCEPTED
Number to Text
2 answers
✓ Accepted answer
You don't have to convert the number into a string to put in in a GUI, assuming that's all you're putting into that specific text field.
You can't, however, do math operations on a string. You have to convert the string into a number, first, using tonumber().
Tostring is the solution to your question. Here is the wiki page explaining this. http://wiki.roblox.com/index.php?title=Function_dump/Basic_functions#tostring I will quickly write out an example
function add(a,b)
return tostring("The answer to "..a.." + "..b.." is "..a + b)
end
print(add(5,5))
-- output: 10
Oops, I misread the question - I got it the wrong way round. ToNumber is the solution you need.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You don't even need tostring for this :P