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:
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”
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)
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.
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)