Ad
Log in to vote
0

Why is my color-change script not working?

Asked by 7 years ago

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

2 answers

Log in to vote
0
Answered by 7 years ago

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.

Also for more information, check these pages:

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
Ad
Log in to vote
0
Answered by
Sciptr 5
7 years ago

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

Answer this question