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

Why does this text label change with the first value, but not change any other time?

I'm trying to make a GUI that changes along with a value, but it only changes the first time.

local text = script.Parent
local val = script.Parent.cash.Value

text.Text = tostring(val) 

val.Changed:Connect(function() 
    text.Text = tostring(val)
end) 

Thanks if you can help.

1 comment

0

Sorry, I messed the title up. I mean the text label changes only one time.

1 answer

DO NOT USE A LOOP (this is to the previous answer)

The reason it doesn't work is that the variable val is an actual number. You can't do .Changed on a number. Here is a complete fix:

local text = script.Parent
local val = script.Parent.cash

text.Text = val.Value

val.Changed:Connect(function() 
    text.Text = val.Value
end) 

When using Variables to define a value, do not put .Value at the end. This is because you want a updating value. The current value will always stay the same if you use the Variable again.

Hopefully, this helped you solve your problem!

If you have any errors Comment below.

Best of luck developer!

2 comments

0

It still doesn't change

0

Maybe because your value isn't changing?

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