Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Trying to sense if ClockTime is in between a value. any help?

Asked by
Kennqu 3
4 years ago

So i am working on a game and noticed the day night system was kind of messed up. The script functioned fine, it changed the time of day, it's just the graphics looked awful. So i'm working on a script to fix this. For the life of me I can't figure out how to detect if Clocktime is in between the values. Im a amuture scripter by the way :P

here is the code:

--This is the day night fix. Makes the night time look better.

--Vars--
local Lighting = game.Lighting
local DayRange = NumberRange(4.3, 18.15)



--Script--
while true do
    if Lighting >= DayRange.Min and Value <= DayRange.Max then
        while true do
            Lighting.Ambient = Color3.new(game.ServerScriptService.DayNightSystem.Day.Amb)
            Lighting.Brightness = game.ServerScriptService.DayNightSystem.Day.Brightness
            Lighting.ColorShift_Top = Color3.new(game.ServerScriptService.DayNightSystem.Day.ColorShiftTop)
            Lighting.EnvironmentDiffuseScale = game.ServerScriptService.DayNightSystem.Day.Diffuse
            Lighting.OutdoorAmbient = Color3.new(game.ServerScriptService.DayNightSystem.Day.OdAmb)
            Lighting.EnvironmentSpecularScale = game.ServerScriptService.DayNightSystem.Day.Specular
            wait(0.01)
        end
    else
        while true do
            Lighting.Ambient = Color3.new(game.ServerScriptService.DayNightSystem.Night.Amb)
            Lighting.Brightness = game.ServerScriptService.DayNightSystem.Night.Brightness
            Lighting.ColorShift_Top = Color3.new(game.ServerScriptService.DayNightSystem.Night.ColorShiftTop)
            Lighting.EnvironmentDiffuseScale = game.ServerScriptService.DayNightSystem.Night.Diffuse
            Lighting.OutdoorAmbient = Color3.new(game.ServerScriptService.DayNightSystem.Night.OdAmb)
            Lighting.EnvironmentSpecularScale = game.ServerScriptService.DayNightSystem.Night.Specular
            wait(0.01)
        end 
        wait(0.01)  
    end
    wait(0.01)
end 

if this needs to be cleaned up please help me out

1 answer

Log in to vote
0
Answered by 4 years ago

something like the following should work.

local Lighting = game:GetService("Lighting")
local min = 1, max = 4


if(Lighting.ClockTime >= min and Lighting.ClockTime <= max) then
    print("The Time is within a range!!")
else
    print"Its not within range ):"
end
1
Thanks! Worked perfect! Kennqu 3 — 4y
Ad

Answer this question