Subjects = {"Math","English","Computer Science" ,"Drama","Geography", "Chemistry","Physics","Physical Education","Economics", "Arts","Biology","History","French"} function subject() if game.Lighting.TimeOfDay == "08:00:00" then for i = 1,6 do while wait(10) do local tempsub = Subjects[math.random(1,#Subjects)] script.Parent.Text = "Subject " .. tempsub end end end end subject()
Three problems,
1) I'm not sure if using the "TimeOfDay" property of lighting is the most effective way of finding the time of day. Instead, i would recommend using the function "GetMinutesAfterMidnight()". You can learn more about that here "http://wiki.roblox.com/index.php?title=Making_a_Day/Night_Cycle"
2) I'm not sure if you were intending this or not. but there is no function to let the script know to repeat until this condition is met. Thus making it run only once and not checking when it's 8 AM.
3) I didn't know if you meant realtime or game time, so I went with real-time 30mins
Subjects = {"Math","English","Computer Science" ,"Drama","Geography", "Chemistry","Physics","Physical Education","Economics", "Arts","Biology","History","French"} function SubjectChange() while true do local tempsub = Subjects[math.random(1,#Subjects)] script.Parent.Text = "Subject " .. tempsub wait(1800) --1800 is 30mins in seconds. if game.Lighting:GetMinutesAfterMidnight() == 15 * 60 then -- this is if you want the subject changes to end at 3PM (or at all). break -- Breaks the loop end end end while wait() do --You can also use "game.Lighting.Changed:connect(function()" for if any property of lighting is changed but unfortunately, this dosen't work on spawn. if game.Lighting:GetMinutesAfterMidnight() == 8 * 60 then -- 8AM SubjectChange() end end
I also added a condition for when it reaches a certain time the loop ends. Hopefully, this helped.