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

How do you convert a number value into a string?

I want to make the name of a part, a number value. (to display via humanoid)

When trying, as in, Blah.Blah.Name = Blah.Blah.Value, it says it needs a string.

Any ideas on how to make it accept the number value? Number value will end up being changed every once and a while, so I can't just use a string.

2 answers

✓ Accepted answer

DawnHorizon mentions the tostring() function, but I think this question deserves a little more detail.

For future reference, you can refer to this page on the Official ROBLOX Wiki, a 'function dump' - a collection of many functions in ROBLOX.

Item #27 on the "Basic Functions" list is tostring(), but if you go to the page you'll also see that #26 is a function called tonumber(). These two functions should be learned in parallel, as one can be used as the inverse of the other.

For example, at the moment you may be wanting to set the Name property of an Instance to a string of a number, and for that you'd use tostring(). Perhaps later on you'll want to retrieve the number value from the Name of that Instance, though, and for that you'd use tonumber().

For example:

number = 5
yourInstance.Name = tostring( number )

--Later, somewhere else
number = tonumber( yourInstance.Name )

3 comments

0

slow clap

0

Though how do I convert a number value? As in, an actual number value?

0

To convert the value of a NumberValue Instance into a string: newString = tostring(yourNumberValue.Value)

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