Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
Ser4v 7
4 years ago

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

Log in to vote
0
Answered by 4 years ago

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!

0
Thank you very much ! It worked perfectly ! Ser4v 7 — 4y
Ad

Answer this question