Unic0de
|
  |
| Joined: 19 Jul 2015 |
| Total Posts: 27 |
|
|
| 28 Jul 2017 10:55 PM |
Now, I have a textlabel that updates its text every time a numervalue is updated / changed. For some reason, the textlabel isn't really updating when the numbervalue is changed.
Here's my script:
while true do wait(.1) script.Parent.Text.Text = script.Parent.Cash.Value end |
|
|
| Report Abuse |
|
|
Laedere
|
  |
| Joined: 17 Jun 2013 |
| Total Posts: 23601 |
|
|
| 28 Jul 2017 10:57 PM |
A TexLabel requires a string, not an integer.
script.Parent.Text.Text = tostring(script.Parent.Cash.Value)
Converting the integer(Cash.Value) into a string should work.
|
|
|
| Report Abuse |
|
|
|
| 28 Jul 2017 10:59 PM |
while true do script.Parent.Text.Text = script.Parent.Cash.Value wait(.1) end
Don't use loops ._. Use Ancestry Changed or :getsignal.. something, I forgot
Wayk Mi Up Insyd |
|
|
| Report Abuse |
|
|
Unic0de
|
  |
| Joined: 19 Jul 2015 |
| Total Posts: 27 |
|
|
| 28 Jul 2017 11:05 PM |
| Strange, it still doesn't work. It's like it's reading the first value and then not reading if it updates. I've checked the numbervalue, it's updating. There's no errors in the output either. |
|
|
| Report Abuse |
|
|
Unic0de
|
  |
| Joined: 19 Jul 2015 |
| Total Posts: 27 |
|
|
| 28 Jul 2017 11:09 PM |
Here's the script that's updating the number value...
(I cut up the script so it's not stolen or anything)
local Cash = game.StarterGui.Cash.Cash -- the numbervalue local stolen = false
if stolen = true then
Cash.Value = Cash.Value +1 |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2017 11:10 PM |
| ### Unless you're working down in the depths with assembly compiled lua, loops are perfectly fine in any shape or form. |
|
|
| Report Abuse |
|
|
BaiYuni
|
  |
| Joined: 09 Oct 2009 |
| Total Posts: 2861 |
|
|
| 28 Jul 2017 11:13 PM |
???
It will still work and does not need to be converted. |
|
|
| Report Abuse |
|
|
BaiYuni
|
  |
| Joined: 09 Oct 2009 |
| Total Posts: 2861 |
|
|
| 28 Jul 2017 11:15 PM |
And you're changing the cash from the StarterGui?
You should be doing it from PlayerGui.
And instead of a loop, it would be more efficient to use Changed or :GetPropertyChangedSignal("Value") |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2017 11:17 PM |
Oh yeah!
its :GetPropertyChangedSignal("Value") I forgot xD
Wayk Mi Up Insyd |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2017 11:18 PM |
Doesn't Changed() fire on any property change? You can even use the parameters and check if the property is the Value property, if I'm not wrong
Pretty sure I've done it, and it's way cleaner than a while loop |
|
|
| Report Abuse |
|
|
BaiYuni
|
  |
| Joined: 09 Oct 2009 |
| Total Posts: 2861 |
|
|
| 28 Jul 2017 11:26 PM |
| Changed fires on any property change that is an Instance. Any other objects such as 'IntValue', 'StringValue', 'NumberValue' etc. only fires when the value changes. |
|
|
| Report Abuse |
|
|
| |
|
Unic0de
|
  |
| Joined: 19 Jul 2015 |
| Total Posts: 27 |
|
|
| 29 Jul 2017 12:03 AM |
| I think it's a glitch or something with onClicked()... idk |
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 29 Jul 2017 12:06 AM |
first off dont name something Text.
also you dont have to convert it to a string, the code below would work fine if you placed and named everything correct.
script.Parent.Cash.Changed:connect(function(x) script.Parent.Text.Text = script.Parent.Cash.Value end)
|
|
|
| Report Abuse |
|
|
BaiYuni
|
  |
| Joined: 09 Oct 2009 |
| Total Posts: 2861 |
|
|
| 29 Jul 2017 12:39 AM |
Why can't you name it Text?
And again, you should be changing the values from PlayerGui, not StarterGui. |
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 29 Jul 2017 12:39 AM |
you can, if it does not have the property Text, but if it does then things can go wrong, it's just overall best to avoid that imo
|
|
|
| Report Abuse |
|
|
BaiYuni
|
  |
| Joined: 09 Oct 2009 |
| Total Posts: 2861 |
|
|
| 29 Jul 2017 12:44 AM |
| So that it's not confusing? I'd agree. |
|
|
| Report Abuse |
|
|