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.

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 
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.

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.

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