Use for tostring()

I know that I can turn a number value into a string using tostring(), but can I turn a string with number into a string? Lets say I have this piece of code:

local text = root
local number = 1
local name = tostring(text + number)

Would that possibly work? If yes, would the result be “root1”?

You’re thinking of concatenation (..) and can be done directly:

local text = "root"
local number = 1
local name = text..number
1 Like

Oh wow. Did not know such thing existed. Thanks!

1 Like

Hello ! You can do like this :

local text = "hello"
local number = 5

print(text.. tostring(number))
1 Like

Awesome! Used your method in my code.

image

Unnecessary tostring call because it’s implicit :stuck_out_tongue_closed_eyes: