Extreme basic time script inquiry!

hello!
im a new developer and i noticed my map looks very bad with the green tint at night but during the morning looks very good

the sime applies but with the color white and opposite order!

i made this simple script and im not getting any errors. i believe i just ordered something incorrectly.

script:

local Time = 0.01
local TimeChange = 0.01

while wait(Time) do
	game.Lighting.ClockTime = game.Lighting.ClockTime + TimeChange
	
end
while true do
	if game.Lighting.TimeOfDay <= "0:5:00:00" then 
		game.Lighting.OutdoorAmbient = ("85, 185, 11")
	else
		game.Lighting.OutdoorAmbient = ("185, 185, 185")
	end
end


this may help:

thank you <3

U need to add a wait function in a loop or the loop will be broken and a spawn function(spawn makes two loops run at same time).

OK, but it still didnt work. (Nothing happens)

edit: the scripts a script
in script storage

local Time = 0.01
local TimeChange = 0.01
spawn(function()
while wait(Time) do
	game.Lighting.ClockTime = game.Lighting.ClockTime + TimeChange

	end
	end)
while true do
	wait()
	if game.Lighting.TimeOfDay <= "0:5:00:00" then 
		game.Lighting.OutdoorAmbient = Color3.new(85, 185, 11)
	else
		game.Lighting.OutdoorAmbient =Color3.new(185, 185, 185)
	end
end

and btw You should use Color3.new()

And take the script to ServerScriptService(If it doesn’t work)

Hey it works but uh -

edit: Whys it so bright?

edit edit: its suppose to be green also

Uhh cuz thats the colour value you kept.You can change it.

its suppose to be green however. what is the color for green?

uhhhh u can go there

Uh you can go choose the colour and then after choosing colour u can paste the numbers between Color3.new()

Sorry i cant tell completly here.Anyways cya.

wait, i changed the script

local Time = 0.01
local TimeChange = 0.01
spawn(function()
	while wait(Time) do
		game.Lighting.ClockTime = game.Lighting.ClockTime + TimeChange

	end
end)
while true do
	wait()
	if game.Lighting.ClockTime <= 4.5 and game.Lighting.ClockTime >= 18  then
		game.Lighting.OutdoorAmbient = Color3.new(0, 1, 0.498039) 
	elseif game.Lighting.ClockTime >= 4.5 and  game.Lighting.ClockTime <= 18 then
		game.Lighting.OutdoorAmbient = Color3.new(1, 1, 1)
	else
		print("error")
	end
end

and it printed “error” meaning the issue is unresolved and the script is still broken!

Sorry i cant solve the outdoorambient it was you who should fix it cuz i gave solution for the topic and i cant give solutions which are not the topic
(Btw u kept the print(error) msg lol)

1 Like

i fixed it by changing and to or. ill give you solution anyways

Just letting you know, spawn() and wait() are becoming deprecated very soon, and have big memory leaks. I just changed it to the newer task.spawn() and task.wait() below. I also added a Property Changed event in so that it will not need to constantly repeat its code. You will understand this code when you become better, and why I did this.

local Time = 0.01
local TimeChange = 0.01

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
	if game.Lighting.ClockTime <= 4.5 and game.Lighting.ClockTime >= 18  then
		game.Lighting.OutdoorAmbient = Color3.new(0, 1, 0.498039) 
	elseif game.Lighting.ClockTime >= 4.5 and  game.Lighting.ClockTime <= 18 then
		game.Lighting.OutdoorAmbient = Color3.new(1, 1, 1)
	else
		print("error")
	end
end)

task.spawn(function()
	while task.wait(Time) do
		game.Lighting.ClockTime = game.Lighting.ClockTime + TimeChange
	end
end)

Enjoy your new script!
Sincerely, Bill