Brick color changing script not working

I want to change the color of the brick according to the time of the day. But it doesn’t seem to be working.

part.BrickColor = BrickColor.new("Institutional white") 

while true do
    wait(0.1)
    local timeoday = game.Lighting.ClockTime 
    if timeoday > 17.6 or timeoday < 6.4 then
 part.BrickColor = BrickColor.new("Institutional white")    
else
 part.BrickColor = BrickColor.new("Really black")    
 end
3 Likes

You forgot to end the loop with ‘end’.

part.BrickColor = BrickColor.new("Institutional white") 

while true do
    wait(0.1)
    local timeoday = game.Lighting.ClockTime 
    if timeoday > 17.6 or timeoday < 6.4 then
 		part.BrickColor = BrickColor.new("Institutional white")    
	else
		part.BrickColor = BrickColor.new("Really black")    
 	end
end

This should be ok. Next time check the output for possible errors.

1 Like

Not really working.

Here are the outputs

18:34:07.988 - Fresno Skyscraper auto-recovery file was created

18:34:09.407 - Workspace.Model.Part.Script:10: ‘end’ expected (to close ‘while’ at line 3) near ‘’

18:34:17.856 - :: Adonis :: Loading Complete; Required by 0.72457488921877.Loader.Loader

You didn’t change anything, that’s why it’s not working. Add the ‘end’ after the last ‘end’.

1 Like

Oh thats the wrong one. Let me find the right one. Sorry :stuck_out_tongue:

This worked

local part = script.Parent

while true do
    wait(.1)
    local timeoday = game.Lighting.ClockTime 
    if timeoday > 17.6 or timeoday < 6.4 then
         script.parent.BrickColor = BrickColor.new("Institutional white")
    else
        script.parent.BrickColor = BrickColor.new("Really black")
    end
end
1 Like

You have to define what ‘part’ is and put something like that at the beginning of the script:
For example

local part = game.Workspace.Baseplate

or

local part = game.Workspace.Car.Seat

depending on where the part is and how it is called.

2 Likes