Goal: When the time is between 20:00 and 5:00 (10 PM and 5 AM) , the material on my light block will be neon and the color will be changed to white.
When I take away the if statement in my code, it works normally.
Also, I’m not very good at scripting, and I couldn’t really find anything online for this.
My code:
I know I made an error 'cause it’s underlined, but I’m not quite sure how I should change it to produce the outcome I want.
My setup:
Thank you!
Dfn150
(DevFunNewIdeas)
August 9, 2022, 1:42am
#2
Ok, so. The second line game.Workspace:GetChildren()
does not need to be there. And the if statement is formatted incorrectly, try this:
if game:GetService("Ligting").TimeOfDay < 5:00:00 and game:GetService("Lighting").TimeOfDay > 20:00:00 then
This should work
1 Like
Try this.
local lighting = game:GetService('Lighting')
local lights = workspace.LightsFolder:GetChildren()
if (light.ClockTime < 5) and (light.ClockTime > 20) then
for _, light in (lights) do
light.Material = Enum.Material.Neon
light.BrickColor = BrickColor.new("White")
end
end
1 Like
Thank you! But, it still appears with an error; any idea? :/D
ayoub50
(Ayoub)
August 9, 2022, 12:39pm
#5
you could do
if game:GetService("Lighting").TimeOfDay < math.floor(5) and game:GetService("Lighting").TimeOfDay > math.floor(20) then
Forummer
(Forummer)
August 9, 2022, 12:42pm
#6
Only the ‘equal to’ and ‘not equal to’ comparison operators are valid for string operands.
1 Like