Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you convert a number value into a string?

Asked by 10 years ago

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

Log in to vote
2
Answered by
duckwit 1404 Moderation Voter
10 years ago

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 )
0
slow clap Maxwell_Edison 105 — 10y
0
Though how do I convert a number value? As in, an actual number value? Maxwell_Edison 105 — 10y
0
To convert the value of a NumberValue Instance into a string: newString = tostring(yourNumberValue.Value) duckwit 1404 — 10y
Ad
Log in to vote
0
Answered by 10 years ago
tostring(numberval) 

Thumb's up if it helps!

Answer this question