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

Brick color changing script not working?

Asked by 5 years ago
local part = script.Parent 
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.Color = BrickColor.new("Institutional white")  

    else
      part.Color = BrickColor.new("Really black")  
end

So here I want to make a brick color change when it's between 17.6 and 6.4. BUt it refuses to work. Why is tha?

2 answers

Log in to vote
0
Answered by
pwx 1581 Moderation Voter
5 years ago

The problem here is you are using 'or' instead of 'and' in your if statement.

Right now, the if statement is basically checking if it's higher than 17.6 or lower than 6.4.

If you want to check between the times, also do note a better way to do this is to use :GetMinutesAfterMidnight().

local part = script.Parent
part.BrickColor = BrickColor.new("Institutional white")

while true do
    wait(.1)
    if game.Lightning:GetMinutesAfterMidnight() > 17.6 * 60 and game.Lightning:GetMinutesAfterMidnight() > 6.4* 60 then
        part.Color = BrickColor.new("Institutional white")
    else
        part.Color = BrickColor.new("Really black") 
    end
end
0
You can also use your method, but you are also missing and end for your if statement. pwx 1581 — 5y
0
Thanks but I am getting this output error clash_ofsss 14 — 5y
0
18:41:32.935 - Lightning is not a valid member of DataModel clash_ofsss 14 — 5y
0
That is odd, maybe try using a variable for lightning. Such as: local Lightning = game:GetService('Lightning'). pwx 1581 — 5y
Ad
Log in to vote
0
Answered by 4 years ago

Old question, but in case anyone comes across this...

Your output window should be showing an error something like:

"invalid argument #3 (Color3 expected, got BrickColor)"

because part.Color needs a Color3 data type, but BrickColor.new returns a BrickColor data type.

To fix this, you need to grab the '.Color' property out of the BrickColor, so it should look like this:

part.Color = BrickColor.new("Really black").Color

Then you're assigning a Color3 to a Color3.

(Also, in the cloud9josh response above, the problem is people keep saying Light-NING when it should be Light-ING).

Answer this question