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

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

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????

2 comments

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.

1 answer

✓ Accepted answer

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.

1 comment

0

Thanks!

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