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

Script for toggling on and off color changing not working. Do I have a syntax error?

Asked by 3 years ago

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

0
String comparison is deprecated: Enum.Material.Neon Ziffixture 6913 — 3y
0
That didn't work, still nothing happens and there's no console output frogeater12345 -3 — 3y
0
I am not giving you a fix, just helping you eradicate bad practices. You should try assigning a BrickColor instead. Ziffixture 6913 — 3y

Answer this question