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

How to change color of Fog?

I have this fog changing coloring script, but for some reason it won't work.

while wait() do
if game.Lighting.TimeOfDay == "06:00:00" then
	script.Parent.FogColor = Color3.new(158,186,250)
else if game.Lighting.TimeOfDay == "19:00:00" then
	script.Parent.FogColor = Color3.new(57,57,57)
		end
	end
end


I assume that my day/night script is interfering with this script, but my lamp script I made works perfectly fine unlike this one.

-- Turning On and off script

		Light = script.Parent.PointLight
while wait() do
if game.Lighting.TimeOfDay == "19:00:00" then
	Light.Enabled = true
	script.Parent.Material = "Neon"
else if game.Lighting.TimeOfDay == "06:00:00" then
	Light.Enabled = false
	script.Parent.Material = "DiamondPlate"
	
	end	
end
end

Any clue on how to get this Fog color change to work?

Here's the day/night script if needed:

l = game:service("Lighting") 
while true do 
l:SetMinutesAfterMidnight(l:GetMinutesAfterMidnight()+0.1)
wait(.1)
end 

2 comments

0

Put a print statement after the if statements in the first script and see if it prints, indicating it got past the if statements..

0

It didn't go through at all. The script isn't disabled either.

1 answer

✓ Accepted answer

In Color3.new(), the values have to be divided by 255 to work, as they have to be in between 0 and 1. You could also work Color3.fromRGB(), if you prefer. You also have an extra end in the first script.

while wait() do
	if game.Lighting.TimeOfDay == "06:00:00" then
		script.Parent.FogColor = Color3.new(158/255, 186/255, 250/255)
	else if game.Lighting.TimeOfDay == "19:00:00" then
		script.Parent.FogColor = Color3.new(57/255, 57/255, 57/255)
	end
end

Also, in the second one, instead of using strings for materials, you should use Enums. It will still work with the strings, but Enums are better to use.

4 comments

0

Thank you, really helped out a lot.

0

No problem.

0

You can simplify line 5 to just Color3.new(57/255)

0

Oh, I wasn't aware of that. Thanks.

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