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

How to convert a number to a string?

This question was here before, but I deleted it because it wasn't typed correctly. Anyway, how can I convert a number to a string?

If I have this script right here:

local value = 1
print(value)

,Then how can I convert "value"'s value into a string, from 1 to "one"?

2 answers

Simply use tostring(), a function that takes a number value and returns a string value. Example code:

local value = 1
local stringvalue = tostring(value)
print(stringvalue)

Edit: I just saw that you wanted a function that returns something like "one" for 1. tostring() would return "1". That would require a bit more scripting. I advise string manipulation for that purpose, found here: http://wiki.roblox.com/index.php?title=Global_namespace/String_manipulation

1 comment

0

thank you!

It's more complicated than you think. However, if you want to make it so that you can use string manipulation on numbers, use tostring. Example:

local value = 1330
local result,found = tostring(value):gsub("0","7")
print(result)
--[[
Output:
1337
]]

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