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

[SOLVED] Why won't my loop script work and update the SurfaceGUI???

Asked by 6 years ago
Edited 6 years ago

Hey guys, scripting a GUI to show the time according to IntValues.. The thing is, I want them to change immediately (or with some delay) when the IntValue value changes. I included my Explorer and the script.

Variables = game.Workspace.Variables
script.Parent.Visible = true

while true do script.Parent.Time.Text = Variables.TV_1SessionTime.Hours.Value..":"..Variables.TV_1SessionTime.Minutes.Value

wait(0.1)

script.Parent.Time.Text = Variables.TV_1SessionTime.Hours.Value..":"..Variables.TV_1SessionTime.Minutes.Value

end

Explorer Screenshot

Why won't it update the GUI????

0
are the values (example: Variables.TV_1SessionTime.Hours.Value) set properly by a remote? if not, it will be set at the client and thus not work. also the imgur link is broken so i can view it. sukkaauto 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Event-driven logic

Conveniently, all *Value types have an overridden Changed event which you can use to do something when the value changes.

local function changeTime()
    Time.Text = Hours.Value .. ":" .. Minutes.Value
end

Hours.Changed:connect(changeTime)
Minutes.Changed:connect(changeTime)

At that point, all you need to do is make sure that Hours and Minutes are actually being changed the way you think they are.

0
Thanks! Doge_Brigade 94 — 6y
Ad

Answer this question