ok so this is the script
local minutes = 0
local hours = 12
local minutesPerGameDay = script.MinutesPerGameDay.Value
local minutesPerSecond = (24/minutesPerGameDay)
local curTime = tick()
local prevTime
while wait() do
prevTime = curTime
curTime = tick()
local dt = curTime - prevTime
minutes = minutes + (minutesPerSecond * dt)
if minutes >= 60 then
minutes = minutes - 60
hours = hours + 1
if hours >= 24 then
hours = 0
end
end
game.Lighting.TimeOfDay = hours .. ":" .. math.floor(minutes) .. ":00"
end
while true do -- this is supposed to change the color correction when its 18:00 and later
if game.Lighting.TimeOfDay >= 18 then game.Lighting.ColorCorrection.TintColor = #a9caff
print('Color Correction Changed its night man')
elseif game.Lighting <= 18 then game.Lighting.ColorCorrection.TintColor = #ffecd0
print('Color Correction Changed back, its day time again :D')
end
end
end
end
--the else if thing should change it back
the first part (until while true do) is part of the roblox’s script.
what im trying to reach is given in the while true do part
Are both while loops inside the same script?
or is the roblox’s script a seperate serverscript?
The second while loop will never run unless the first one is stopped. And while wait() do will always be true, so the first while loop will never stop.
1 Like
Yep, same script inside of serverscript service, btw what mumber should i put inside the wait and why is it necessary, so do i have to put em into seperate scripts?
Ps i just misread your msg, read my reply again
You could combine both while loops into one, Just put the if statement from the second loop in the first loop at the end.
You should not check for game.Lighting.TimeOfDay >= 18 since, the TimeOfDay won’t return an integer with the hour. TimeOfDay returns a string representing the time including minutes:
Use game.Lighting.ClockTime as this returns a float between 0 and 24
local minutes = 0
local hours = 12
local minutesPerGameDay = script.MinutesPerGameDay.Value
local minutesPerSecond = (24/minutesPerGameDay)
local curTime = tick()
local prevTime
while true do
prevTime = curTime
curTime = tick()
local dt = curTime - prevTime
minutes = minutes + (minutesPerSecond * dt)
if minutes >= 60 then
minutes = minutes - 60
hours = hours + 1
if hours >= 24 then
hours = 0
end
end
game.Lighting.TimeOfDay = hours .. ":" .. math.floor(minutes) .. ":00"
if game.Lighting.ClockTime >= 18 then
--handle the lighting
elseif game.Lighting.ClockTime <= 18 then
--handle the lighting
end
end
2 Likes
So do i input that code into mine and edit it after the “then’s”
You could replace the code you have with the code I’ve written down since I’ve copied it. I’m not sure if it will work though since I have not checked whether the first while loop of yours works correctly. I assume it does.
1 Like
Im goung to check that out later, thx in advance
1 Like
i got it working, btw the part with the color chanigng had to be used with three values and Color3.newRGB or something i got it working with help on Script Helpers discord
thanks for doing your part!