Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

BrickColor is not changing?

Asked by 9 years ago

I think I'm starting to get the hang of scripting, but for some reason, the brick wont change colors. Please help

if game.Lighting.TimeOfDay >= "18:00:00" then
    script.Parent.BrickColor = BrickColor.new("Yellow") elseif
    game.Lighting.TimeOfDay >= "6:00:00" then
        script.Parent.BrickColor = BrickColor.new("Really Black")

end

1 answer

Log in to vote
2
Answered by
Wizzy011 245 Moderation Voter
9 years ago

Neither Yellow nor Really Black are colors, there's Really yellow or New Yeller as well as Really black. (The capitalisation is key)

If you're checking the time of day, you may want to put the code into a function using the Changed event to check the current TimeOfDay, when it changes.

You could write this as:

game.Lighting.Changed:connect(function()
    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)
0
Oh. :l branflakes1099 30 — 9y
Ad

Answer this question