NumberValue text live changes does not change

If I set My NumberValue to 9 in studio mode it displays the text as 9.
but when I do that:
it does not make live changes…
I don’t Know why.
please help Me…

local text = script.Parent

local number = script.Parent.Number

text.Text = number.Value

while true do

number.Value = number.Value + 1

wait()

end

Nevermind! I had to put the variable inside the while true do line…

while true do

    text.Text = number.Value

    number.Value = number.Value + 1

    wait()

    end

Yes, it won’t make changes live, because you only update the TextLabel once. You need to update the text every time the value changes. The best way to do this is through a Changed event and not through the while loop: use events over loops where you can.

local text = script.Parent
local number = script.Parent.Number

local function updateText(number)
    text.Text = number
end

number.Changed:Connect(updateText)
updateText(number)

while true do
    number.Value = number.Value + 1
    wait()
end

Is what I did fine? putting the text.Text = number.Value
inside this line

while true do

text.Text = number.Value

number.Value = number.Value + 1

wait()

end

Makes it work…

Full script.

local text = script.Parent

local number = script.Parent.Number

while true do

text.Text = number.Value

number.Value = number.Value + 1

wait()

end

It is, but I encourage you to use events where you can. I’m making the assumption that other things can influence what the value of the number is and the while loop is just for testing purposes which is why I suggested an alternative way for doing this.

1 Like