I have just come up with this script to turn on lights in a building I have made.
while true do wait(.2) function lights() if game:GetService("Lighting"):GetMinutesAfterMidnight() <= 6*60 then script.Parent.BrickColor = BrickColor.new("Cork") script.Parent.Material = "Neon" script.Parent.Reflectance = 0 script.Parent.Transparency = 0.2 elseif game:GetService("Lighting"):GetMinutesAfterMidnight() >= 7*60 then script.Parent.BrickColor = BrickColor.new ("Bright bluish green") script.parent.Material = "Glass" script.Parent.Reflectance = 0.3 script.Parent.Transparency = 0 end end lights() end
I have tried switching game:Getservice("Lighting"):GetMinutesAfterMidnight() to game.Lighting.ClockTime, but neither is working. It still works while running, but refuses to work after I spawn in my character. I'm very new to scripting so I apologize if there is an obvious fix.
I have also tried this in both normal and local scripts. The normal script at least works when running the game, the local script didn't work at all. Still the same issue.
while true do wait(.2) function lights() local lighting = game:GetService("Lighting"):GetMinutesAfterMidnight() if lighting <= 6*60 then script.Parent.BrickColor = BrickColor.new("Cork") script.Parent.Material = "Neon" script.Parent.Reflectance = 0 script.Parent.Transparency = 0.2 elseif lighting >= 7*60 then script.Parent.BrickColor = BrickColor.new ("Bright bluish green") script.parent.Material = "Glass" script.Parent.Reflectance = 0.3 script.Parent.Transparency = 0 end end lights() end
I have just figured it out, when I changed the time while playing I was only changing it client side, not server side. I added Khol's admin for a sec, because I figured that using the :time command would change the time server side. Sure enough, even my first script worked. Thank you to everyone who responded! :)