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

How to change color of Fog?

Asked by 8 years ago

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

1while wait() do
2if game.Lighting.TimeOfDay == "06:00:00" then
3    script.Parent.FogColor = Color3.new(158,186,250)
4else if game.Lighting.TimeOfDay == "19:00:00" then
5    script.Parent.FogColor = Color3.new(57,57,57)
6        end
7    end
8end

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

01-- Turning On and off script
02 
03        Light = script.Parent.PointLight
04while wait() do
05if game.Lighting.TimeOfDay == "19:00:00" then
06    Light.Enabled = true
07    script.Parent.Material = "Neon"
08else if game.Lighting.TimeOfDay == "06:00:00" then
09    Light.Enabled = false
10    script.Parent.Material = "DiamondPlate"
11 
12    end
13end
14end

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

Here's the day/night script if needed:

1l = game:service("Lighting")
2while true do
3l:SetMinutesAfterMidnight(l:GetMinutesAfterMidnight()+0.1)
4wait(.1)
5end
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.. dragonkeeper467 453 — 8y
0
It didn't go through at all. The script isn't disabled either. RadioactiveP0P 44 — 8y

1 answer

Log in to vote
1
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

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.

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

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.

0
Thank you, really helped out a lot. RadioactiveP0P 44 — 8y
0
No problem. Pyrondon 2089 — 8y
0
You can simplify line 5 to just Color3.new(57/255) User#5423 17 — 8y
0
Oh, I wasn't aware of that. Thanks. Pyrondon 2089 — 8y
Ad

Answer this question