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

Ambient only changes once?

Asked by 9 years ago

So basically a day and night script but at certain times the Ambient and such changes to create a better look. It works the first day but the second night nothing changes. I assume it's that the TimeOfDay doesn't hit these numbers the second time around. So is there a better way to do this? It doesn't have to be at these exact times just is there a better working way to make sure the Ambient changed every night and day?

local lig = game:GetService("Lighting") 

while true do
    lig:SetMinutesAfterMidnight(lig:GetMinutesAfterMidnight()+0.1) 
    wait(-8) 
    if lig.TimeOfDay == "17:50:13" then
        lig.Ambient = Color3.new(55/255, 55/255, 55/255)
        lig.OutdoorAmbient = Color3.new(90/255, 90/255, 90/255)
        lig.Brightness = "0.5"
    elseif lig.TimeOfDay == "18:45:32" then
        lig.Ambient = Color3.new(0/255, 0/255, 0/255)
        lig.OutdoorAmbient = Color3.new(24/255, 24/255, 24/255)
        lig.Brightness = "0.3"
    elseif lig.TimeOfDay == "05:35:26" then
        lig.Ambient = Color3.new(55/255, 55/255, 55/255)
        lig.OutdoorAmbient = Color3.new(90/255, 90/255, 90/255)
        lig.Brightness = "0.5"
    elseif lig.TimeOfDay == "06:25:26" then
        lig.Ambient = Color3.new(126/255, 126/255, 126/255)
        lig.OutdoorAmbient = Color3.new(182/255, 182/255, 182/255)
        lig.Brightness = "2"
    end
end

1 answer

Log in to vote
0
Answered by 9 years ago

TimeOfDay and brightness is a number, not string. Try this instead:

local lig = game:GetService("Lighting") 

while true do
    lig:SetMinutesAfterMidnight(lig:GetMinutesAfterMidnight()+0.1) 
    wait(-8) 
    if lig.TimeOfDay == 175013 then
        lig.Ambient = Color3.new(55/255, 55/255, 55/255)
        lig.OutdoorAmbient = Color3.new(90/255, 90/255, 90/255)
        lig.Brightness = 0.5
    elseif lig.TimeOfDay == 184537 then
        lig.Ambient = Color3.new(0/255, 0/255, 0/255)
        lig.OutdoorAmbient = Color3.new(24/255, 24/255, 24/255)
        lig.Brightness = 0.3
    elseif lig.TimeOfDay == 053526 then
        lig.Ambient = Color3.new(55/255, 55/255, 55/255)
        lig.OutdoorAmbient = Color3.new(90/255, 90/255, 90/255)
        lig.Brightness = 0.5
    elseif lig.TimeOfDay == 062526 then
        lig.Ambient = Color3.new(126/255, 126/255, 126/255)
        lig.OutdoorAmbient = Color3.new(182/255, 182/255, 182/255)
        lig.Brightness = 2
    end
end
Ad

Answer this question