Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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 comment

1

Thanks! Worked perfect!

This discussion is preserved as it was. New answers, comments, and votes are closed.