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:
value/20.
I was really not sure how to explain this, I’m sorry if it’s not clear enough.
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”)
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.
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?
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.
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.
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.