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

What's wrong with my color changing script?

Asked by 7 years ago

If you remember me a month ago, I knew nothing about lua. Now I know a lot more.

Okay anyways, back to my question. I'm trying to make a color changing brick, and what's wrong with this script?

while true do

change = game.Workspace.Part --Part is the brick I'm trying to change.

change.BrickColor = BrickColor.new "Really red"
wait(1)
change.BrickColor = BrickColor.new "Lime green"

end

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

This is just a simple logical error, we change the block to Really red then wait 1 and change it to Lime green but we do not wait so we change it to Really red. As not enough time has passed we cannot see the change.

We simple need another wait (keeping the code simple):-

while true do

-- we only need to get this once so there is no need for it to be in the loop.
change = game.Workspace.Part

change.BrickColor = BrickColor.new "Really red"
wait(1)
change.BrickColor = BrickColor.new "Lime green"
wait(1) -- we wait again

end

I hope this helps.

Ad

Answer this question