Schedule Text changing with "ClockTime"

Hello there, I am trying to build a schedule which changes at specific times in ClockTime (under lighting) I have already tried several scripts but none of them really worked as I dont really script good. I wanted to ask if anyone of you knows any DevForum Articles, scripts or YouTube videos which could help me. Thank you.

Example of what I mean:

image

If “ClockTime” under lighting hit 7am the TextLabel Text should change to “Breakfast”
If it hits for 10pm the Text should change to “Room Time”

Show us your current script and we can help you improve.

This is how I would do it:

local Schedule = {
   ["7"] = "Breakfast",
   ["22"] = "Room Time"
}
--Create a library which stores what you want to to be on the schedule
--ClockTime uses 24/h time, so 10pm would be 22
--Libraries act weird when you use numbers as the indexes, so I turn them to strings

local IntTime = Instance.new("IntValue", script)
IntTime.Changed:Connect(function()
   local Str = Schedule[tostring(IntTime.Value)]
   --Assign 'Str' to whatever is stored in the library under the current clocktime, if there is something
   if Str then
      --If this conditional passes, then something was found in the library
      print("It is now " .. Str)
   end
end)

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
   --Fires when ClockTime has changed, at all
   IntTime.Value = math.floor(game.Lighting.ClockTime)
end)
2 Likes

I believe there is like a method called get minutes from daylight where you could then divide it by 60 to get the current time in hours

It seems to me like you already have what you need accomplished.

If I’m understanding this correctly, you want the ClockTime (which by the way, Lighting has another property to display the 12 hour clock time as a string) to determine when the text on that GUI is?

Well you already have it, all you have to do is add something like this in your IntTime.Changed() event.

MyGui.Text = Str

So I tried to take your script and change it up a little and it works for the first part, problem: It doesnt change from the breakfast how do I fix that? (Adding to this I have very small knowlege in scripting so maybe I completly ruined it sorry

local Schedule = {

["7"] = "Breakfast",

["10"] = "Free Time",

["22"] = "Room Time"

}

--Create a library which stores what you want to to be on the schedule

--ClockTime uses 24/h time, so 10pm would be 22

--Libraries act weird when you use numbers as the indexes, so I turn them to strings

local IntTime = Instance.new("IntValue", script)

IntTime.Changed:Connect(function()

local Str = Schedule[tostring(game.Lighting.ClockTime)]

--Assign 'Str' to whatever is stored in the library under the current clocktime, if there is something

if Str then

--If this conditional passes, then something was found in the library

script.Parent.Text = Str

end

end)

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()

--Fires when ClockTime has changed, at all

IntTime.Value = math.floor(game.Lighting.ClockTime)

end)

That’s not the OP :slightly_smiling_face:

The OP is @0kdevilz

Oh my goodness!!

Well this is embarrassing.

So sorry I thought that was OP.

No worries, it’s not working because of a mistake I made actually.

Replace local Str = Schedule[tostring(game.Lighting.ClockTime)]
with local Str = Schedule[tostring(IntTime.Value)]

It works now Thank you very much