Hello! I want to make my game more realistic by making it darker at night and lighter during the day. After figuring out how to do this, I made a script and it worked inside Roblox studio.
However, whenever I publish my game to Roblox and play it from the Roblox browser, the lighting script does not work. I feel if it works in Roblox studio it should also work in Roblox player.
I have tried modifying the script below and set the start time to 12. I’ve also tried looking around the DevForum but with no luck in finding solutions. It should also be noted I am not the best at scripting. Could this be an issue with my script or Roblox?
This is the script I’ve been using:
while true do
if game.Lighting.ClockTime == 17.50 then
game.Lighting.Ambient = Color3.fromRGB(90,90,90)
game.Lighting.OutdoorAmbient = Color3.fromRGB(90,90,90)
game.Lighting.Brightness = 2.7
wait(5)
game.Lighting.Ambient = Color3.fromRGB(80,80,80)
game.Lighting.OutdoorAmbient = Color3.fromRGB(80,80,80)
game.Lighting.Brightness = 2.4
wait(5)
game.Lighting.Ambient = Color3.fromRGB(70,70,70)
game.Lighting.OutdoorAmbient = Color3.fromRGB(70,70,70)
game.Lighting.Brightness = 2.1
wait(5)
game.Lighting.Ambient = Color3.fromRGB(60,60,60)
game.Lighting.OutdoorAmbient = Color3.fromRGB(60,60,60)
game.Lighting.Brightness = 1.8
wait(5)
game.Lighting.Ambient = Color3.fromRGB(50,50,50)
game.Lighting.OutdoorAmbient = Color3.fromRGB(50,50,50)
game.Lighting.Brightness = 1.5
wait(5)
game.Lighting.Ambient = Color3.fromRGB(40,40,40)
game.Lighting.OutdoorAmbient = Color3.fromRGB(40,40,40)
game.Lighting.Brightness = 1.2
wait(5)
game.Lighting.Ambient = Color3.fromRGB(30,30,30)
game.Lighting.OutdoorAmbient = Color3.fromRGB(30,30,30)
game.Lighting.Brightness = 0.9
wait(5)
game.Lighting.Ambient = Color3.fromRGB(20,20,20)
game.Lighting.OutdoorAmbient = Color3.fromRGB(20,20,20)
game.Lighting.Brightness = 0.6
wait(5)
game.Lighting.Ambient = Color3.fromRGB(10,10,10)
game.Lighting.OutdoorAmbient = Color3.fromRGB(10,10,10)
game.Lighting.Brightness = 0.3
wait(5)
game.Lighting.Ambient = Color3.fromRGB(0,0,0)
game.Lighting.OutdoorAmbient = Color3.fromRGB(0,0,0)
game.Lighting.Brightness = 0
wait(1)
elseif game.Lighting.ClockTime == 6 then
game.Lighting.Ambient = Color3.fromRGB(10,10,10)
game.Lighting.OutdoorAmbient = Color3.fromRGB(10,10,10)
game.Lighting.Brightness = 0.3
wait(5)
game.Lighting.Ambient = Color3.fromRGB(20,20,20)
game.Lighting.OutdoorAmbient = Color3.fromRGB(20,20,20)
game.Lighting.Brightness = 0.6
wait(5)
game.Lighting.Ambient = Color3.fromRGB(30,30,30)
game.Lighting.OutdoorAmbient = Color3.fromRGB(30,30,30)
game.Lighting.Brightness = 0.9
wait(5)
game.Lighting.Ambient = Color3.fromRGB(40,40,40)
game.Lighting.OutdoorAmbient = Color3.fromRGB(40,40,40)
game.Lighting.Brightness = 1.2
wait(5)
game.Lighting.Ambient = Color3.fromRGB(50,50,50)
game.Lighting.OutdoorAmbient = Color3.fromRGB(50,50,50)
game.Lighting.Brightness = 1.5
wait(5)
game.Lighting.Ambient = Color3.fromRGB(60,60,60)
game.Lighting.OutdoorAmbient = Color3.fromRGB(60,60,60)
game.Lighting.Brightness = 1.8
wait(5)
game.Lighting.Ambient = Color3.fromRGB(70,70,70)
game.Lighting.OutdoorAmbient = Color3.fromRGB(70,70,70)
game.Lighting.Brightness = 2.1
wait(5)
game.Lighting.Ambient = Color3.fromRGB(80,80,80)
game.Lighting.OutdoorAmbient = Color3.fromRGB(80,80,80)
game.Lighting.Brightness = 2.4
wait(5)
game.Lighting.Ambient = Color3.fromRGB(90,90,90)
game.Lighting.OutdoorAmbient = Color3.fromRGB(90,90,90)
game.Lighting.Brightness = 2.7
wait(5)
game.Lighting.Ambient = Color3.fromRGB(100,100,100)
game.Lighting.OutdoorAmbient = Color3.fromRGB(100,100,100)
game.Lighting.Brightness = 3
wait(1)
end
wait(1)
end