0

# Why is my color-change script not working?

Welp here it is. Please keep in mind that this is my FIRST REAL SCRIPT for a game.

while true do workspace.lunarbutton.brickcolor = BrickColor.blue workspace.lunarbutton.brickcolor = BrickColor.red

end

0
I hope everyone understands that I want a LOOP! Right? I want it to do this infinetly. pedrosantaana 0 — 7y

0

That's not how you declare the part's color. In order to do this, you have to use BrickColor.new. Here's one way how it works:

while true do -- declare the loop
wait() -- make sure to add a wait() to avoid crashing
workspace.lunarbutton.BrickColor = BrickColor.new("Bright blue") --We access the part's color and change it to bright blue
wait(2) -- we wait a few seconds again
workspace.lunarbutton.BrickColor = BrickColor.new("Really red") -- The part is now red.
end


Another way to do this is by:

workspace.lunarbutton.BrickColor = BrickColor.Red() --This will make the part's color to red
workspace.lunarbutton.BrickColor = BrickColor.Blue() -- This will turn blue


Keep in mind that there are other types of shades of blue and red. To access these colors, go on studio and you will find a list of colors with their corresponding names.

http://wiki.roblox.com/index.php?title=Color

http://wiki.roblox.com/index.php?title=BrickColor

0
It doesn't seem to be looping. Even though I fixed everything. pedrosantaana 0 — 7y
0
I've tested it myself and it works fine. Try adjusting the wait time. Darknesschaos 0 — 7y
0
Okay...i'll try again. Sorry for the nubby-ness. It is my first script after all. pedrosantaana 0 — 7y
0

Welcome to scripting, here is your script:

while true do workspace.lunarbutton.brickcolor = BrickColor.blue workspace.lunarbutton.brickcolor = BrickColor.red

end


you already have some issues, while im short on time atm I will fix your code, comment or PM me and ill explain the changes.

function change()
local brickname="Part"
brick = game.Workspace:FindFirstChild(brickname)
brick.BrickColor=BrickColor.Red()
end

change()


I hope it helps! -Sciptr