I am trying to build a schedule for my game, and I came up with a solution like this:
local lighting = game:GetService("Lighting") local current = game.StarterGui.Schedule.viewschedule.current local nexts = game.StarterGui.Schedule.viewschedule.next local tim = lighting.ClockTime if tim >= 7 then current.Text = ("Wake Up") nexts.Text = ("Math Class") end if tim >= 8 then current.Text = ("Math Class") nexts.Text = ("Study Hall") end if tim >= 10 then current.Text = ("Study Hall") nexts.Text = ("Lunchtime") end if tim >= 12 then current.Text = ("Lunchtime") nexts.Text = ("Reading Class") end if tim >= 14 and tim <= 16 then current.Text = ("Reading Class") nexts.Text = ("Science Class") end if time >= 16 then current.Text = ("Science Class") nexts.Text = ("Dinner") end if time >= 18 then current.Text = ("Dinner") nexts.Text = ("Party Time") end if time >= 20 then current.Text = ("Party Time") nexts.Text = ("Bed Time") end if time >= 22 then current.Text = ("Bed Time") nexts.Text = ("Wake Up") end
When I test it in game, the text will not update. It starts on Reading Class and Science Class because the test starts at 15 on the Clock Time, but it won't update when it turns to 16. Why is that?
Hey there, bobthetomato5
If you haven't noticed already, on line 31 and so forth you start saying time
instead of tim
. You are not referencing your variable correctly. Please leave comments if you have any more issues.
Alright, hello Bob. So, StarterGui is only updated when the player joins/respawns. To change the text in a gui for all players, you will have to do something like this.
local lighting = game:GetService("Lighting") local tim = lighting.ClockTime function changeText(current, nexts) for i,v in pairs(game.Players:GetPlayers()) do v.PlayerGui.Schedule.viewschedule.current.Text = current v.PlayerGui.Schedule.viewschedule.next.Text = nexts end end if tim >= 7 then changeText("Wake Up", "Math Class") -- So basically you do changeText(current text, next text) end if tim >= 8 then changeText("Math Class", "Study Hall") end if tim >= 10 then changeText("Study Hall", "Lunchtime") end -- I believe you can do the rest yourself