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

How can I change the value in my text label when it increase ?

So, i'm trying to make my first tycoon and the screen where is the amount of money I can collect has a text label in a SurfaceGUI where it's written. But when I do text = value (for example because it doesn't look like that in my script) the text is still 0 while the value of the amount increased.

I need help with it and sorry if you don't understand everythings, it's because I'm french and I'm still learning english...

1 answer

✓ Accepted answer

You can either use a loop or a changed event.

To use a loop you can do it with while wait

local MoneyValue = pathtoyourvalue --// Put where it is located

local Label = pathtothetextlabel --// Put where the text label is located

while wait() do
-- Incase the MoneyValue is an IntValue or NumberValue we use tostring

Label.Text = tostring(MoneyValue.Value) 

end

Since this may lag you should not use that, but you can use Changed, in this case we won't use it since it's just the Value property, so we use Instance:GetPropertyChangedSignal

local MoneyValue = pathtoyourvalue --// Put where it is located

local Label = pathtothetextlabel --// Put where the text label is located

function OnChange()
-- Incase the MoneyValue is an IntValue or NumberValue we use tostring

Label.Text = tostring(MoneyValue.Value) 

end

local Signal = MoneyValue:GetPropertyChangedSignal("Value") --// We get the PropertyChanged RBXScriptSignal

Signal:Connect(OnChange) --// We connect it to the OnChange function

And that's it! If this answered your question, accept it!

1 comment

0

Thank you very much ! It worked perfectly !

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