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

How to make text update to value?

Asked by 3 years ago

I'm trying to make a text in a gui, (TimerText), be set to the value of TimeValue. It seems that TimerText is not updating although it is ran in a while true loop. I made sure that TimeValue is being changed through prints, so that shouldn't be the problem. Does anyone have any ideas of what I'm doing wrong?


local TimeValue = game.StarterPlayer.StarterPlayerScripts.LocalTimer.Time.Value local TimerText = game.StarterGui:WaitForChild("ScreenGui"):WaitForChild("Timer").Text while true do TimerText = TimeValue wait(.1) end

1 answer

Log in to vote
0
Answered by 3 years ago

TimerText is a string. You want the object. You also want to put the variables in the loop so it fetches the updated values

local TimerText = game.StarterGui:WaitForChild("ScreenGui"):WaitForChild("Timer")
while true do
    local TimeValue = game.StarterPlayer.StarterPlayerScripts.LocalTimer.Time.Value
    TimerText.Text = TimeValue
    wait(.1)
end

You can shorten it more but no need. If you have any questions or if something doesn't work, comment below and I'll reply. Make sure to click accept if it does work.

Ad

Answer this question