I am building a game that needs a schedule, and I wrote a script that I thought would work, but didn't. I then asked for help on this forum, and was given some, but the script given to me as a solution didn't work either for updating the text.
Here is the script (its a script in serverscriptservice:
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 >= 6 then changeText("Wake Up", "Math Class") end if tim >= 8 then changeText("Math Class", "Break Time") -- So basically you do changeText(current text, next text) end if tim >= 10 then changeText("Break Time", "Lunch Time") end if tim >= 12 then changeText("Lunchtime", "Reading") end if tim >= 14 then changeText("Reading", "Science") end if tim >= 16 then changeText("Science", "Dinner") end if tim >= 18 then changeText("Dinner", "Freetime") end if tim >= 20 then changeText("Freetime", "Bedtime") end if tim >= 22 then changeText("Bedtime", "Wake Up") end
So my question is how do you update the text for everyone on the server without resetting your player?
You need to use a local script, not a server script you dumb
Your script will only run once so use a while loop so that it always runs and arrange all your if statements from highest to lowest since they will be satisfied.
local lighting = game:GetService("Lighting") local tim = lighting.ClockTime local 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 >= 22 then changeText("Bedtime", "Wake Up") end if tim >= 20 then changeText("Freetime", "Bedtime") end if tim >= 18 then changeText("Dinner", "Freetime") end if tim >= 16 then changeText("Science", "Dinner") -- So basically you do changeText(current text, next text) end if tim >= 14 then changeText("Reading", "Science") end if tim >= 12 then changeText("Lunchtime", "Reading") end if tim >= 10 then changeText("Break Time", "Lunch Time") end if tim >= 8 then changeText("Math Class", "Break Time"") end if tim >= 6 hen changeText("Wake Up", "Math Class") end