Adding on to text?

So, I have a value (number value) that will range from 0-20,
I want a script to display this value on a TextLabel, but with an added /20.
My finished text would say:

I was really not sure how to explain this, I’m sorry if it’s not clear enough.


I believe I understand what you’re trying to say.

Here’s an example you can put into a local script just to try it out and work off of it:

local number =, 20)

TextLabel.Text = number..'/20'

Aren’t those supposed to be double quotes?

You can use single or double quotes. It makes no difference and really comes down to preference.


You can also use string.format to combine strings and numbers. Here is an example:

local number = 10

TextLabel.Text = string.format("%d/20", number)

print(TextLabel.Text) -- "10/20"

Plug in: the concept you’re referring to is concatenation - string concatenation, more specifically.


you have to specify whether the number value is in the leaderstats or in the workspace.
So, you’re going to have to use a local script and set the parent to the text label

for if the number value is in the leaderstats:

local Number = game.Players.LocalPlayer:WaitForChild(“YourLeaderstatName”):WaitForChild(“YourStatName”)

    script.Parent.Text = Number.Value.."20"

If you can directly reference it. use this script:

local Number = [Find the number value using script.Parent].Value

    script.Parent.Text = Number.Value.."20"

The if statement is unnecessary. Value objects have a specially designed version of Changed that only fires when the value changes and the new value is supplied as a parameter. In addition, your code would not run because value cannot be both the string Value and the value of the ValueObject.

1 Like

I just realized I used value as the parameter when I should’ve put something such as “newvalue” to clarify that you’d need to use the new value of “(number)”.

As for the if statement, for one, I am accustomed to events which is why I wrote the if statement to check if the value exists, and as for the “specially designed version of changed”, I was not aware that was a thing, could you send me the api page including it?

This is something you can search yourself.

ValueObjects do not inherit Changed from Instance. In addition, a superclass for them was not made until later so each of their events pages are different. Here is an example: Changed of StringValues.

And yet I somehow still don’t see the issue with including the check; it is not harming the integrity of the script in anyway.

I’ve already stated what the problem was: the check is unnecessary and it doesn’t even function fully. “It doesn’t harm the script’s integrity” isn’t really proper justification as to why you’d want to make your script do more unnecessary work. As for the code not working, I have highlighted this in a previous reply: please review it.

1 Like

I clearly acknowledged the error I made, and again; while it may be unnecessary it is not causing the script to not function.

It’s not about whether the code functions or not at all. It’s unnecessary and there is no reason to be doing that, which is what I pointed out. It’s better to suggest proper code and, if error is acknowledged, to correct it rather than to leave it as a mistake.

NumberValue.Changed:Connect(function (newNumber)
    TextLabel.Text = newNumber.."/20"