So I'm making a game that has a color changing brick, but the brick is only supposed to change colors when a power button's material is neon. Here's my code:
local RGBBrick = script.Parent local button = script.Parent.Parent.Parent.PowerButton local r = 250 local g = 0 local b = 0 while true do if button.Material == "Neon" then RGBBrick.Material = "Glass" RGBBrick.Color = Color3.fromRGB(255,255,255) else RGBBrick.Material = "Neon" for x=0,10,1 do g=g+25 RGBBrick.Color = Color3.fromRGB(r,g,b) wait(0.1) end for x=10,0,1 do r=r-25 RGBBrick.Color = Color3.fromRGB(r,g,b) wait(0.1) end for x=0,10,1 do b=b+25 RGBBrick.Color = Color3.fromRGB(r,g,b) wait(0.1) end for x=10,0,1 do g=g-25 RGBBrick.Color = Color3.fromRGB(r,g,b) wait(0.1) end for x=0,10,1 do r=r+25 RGBBrick.Color = Color3.fromRGB(r,g,b) wait(0.1) end for x=10,0,1 do b=b-25 RGBBrick.Color = Color3.fromRGB(r,g,b) wait(0.1) end end
I have it so the power button changes to neon material when it's clicked, but to plastic if its already neon. The power button works fine, but nothing happens to the RGB Brick. It's supposed to change color as you can imagine, and I've tested just the color changing part alone and that works, so I think it's a problem with getting the material or the while true do loop. I'm not getting any errors either in the console