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.
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!