For some reason the first equal sign shows up as an error in the script. The script isn't working, either. What am I doing wrong?
if game.Lighting.TimeOfDay = "18:00:00" then script.Parent.BrickColor = BrickColor.new("Really yellow") elseif game.Lighting.TimeOfDay = "6:00:00" then script.Parent.BrickColor = BrickColor.new("Really black") end
Same thing as funyun said but:
game:GetService("Lighting").Changed:connect(function() --Use Changed instead of while loops to make less lag if game.Lighting.TimeOfDay == "18:00:00" then script.Parent.BrickColor = BrickColor.new("New yeller") --Really yellow is not a color! elseif game.Lighting.TimeOfDay == "6:00:00" then script.Parent.BrickColor = BrickColor.new("Really black") end end)
Hope it helps!
In conditionals, if you want to check if two things are equal, you use ==, not =. When you're setting values, like changing a part's BrickColor, you use =.
You will also need to constantly check the time. When the game runs, the script will only check the time once, and then it will do nothing else. Let's make a loop to solve this.
while wait() do --Every time this loop runs, it will check the time, and if the time is 6 AM or 6 PM, it will do the stuff. if game.Lighting.TimeOfDay == "18:00:00" then script.Parent.BrickColor = BrickColor.new("Really yellow") elseif game.Lighting.TimeOfDay == "6:00:00" then script.Parent.BrickColor = BrickColor.new("Really black") end end