I am trying to get this script to work but it wont.
When I manually change the time it works, but when I have a time changing script it just doesn’t.
How do I add a time range to this.
lighting.Changed:Connect(function(prop)
if prop == 'ClockTime' then
local currentTime = clockAnnouncements[lighting.ClockTime]
if currentTime then
local title = currentTime.Title
local desc = currentTime.Description
local notificationUI = script.at_lst12778.Notifications:Clone()
notificationUI.notif.descw.Text = desc
notificationUI.notif.titlew.Text = title
notificationUI.Name = player.Name..' \'s Notifications'
notificationUI.Parent = playerGui
wait(5)
notificationUI:Destroy()
end
end
end)
Please attach your time changing script to this, as the problem can not be fully solved without the full problem.
Additionally, you should not be setting ClockTime (You might be, I do not have that script). It would be easier in your case to use :SetMinutesAfterMidnight and :GetMinutesAfterMidnight. For a working example, see the post I solved below:
local dayLength = 12
local cycleTime = dayLength*20
local minutesInADay = 24*20
local lighting = game:GetService("Lighting")
local startTime = tick() - (lighting:getMinutesAfterMidnight() / minutesInADay)*cycleTime
local endTime = startTime + cycleTime
local timeRatio = minutesInADay / cycleTime
if dayLength == 0 then
dayLength = 1
end
repeat
local currentTime = tick()
if currentTime > endTime then
startTime = endTime
endTime = startTime + cycleTime
end
lighting:setMinutesAfterMidnight((currentTime - startTime)*timeRatio)
wait(1/15)
until false
Why is that so complicated? You could just do something like this: (Try it)
This also prevents overflow, as set takes that into account. You can also get the time from any other script.
local minPerSec = 1; --How many minutes pass every real life second
--Set the above to 1/60 for real time
local lighting = game:GetService('Lighting')
local lastTick = tick()
while true do
local cur = lighting:GetMinutesAfterMidnight()
cur = cur + (minPerSec*(tick()-lastTick))
lighting:SetMinutesAfterMidnight(cur)
lastTick = tick()
wait()
end