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

When I click the part the color changing script won't work, why is that?

Asked by 4 years ago
Edited 4 years ago

This is supposed to make it so that when you press a button light12 turns white

local db = true
local click = script.Parent.ClickDetector
click.MouseClick:Connect(function()
    script.Parent.BrickColor = BrickColor.new("Black")
    wait(1)
    if  script.Parent.BrickColor == "Black" then
        game.workspace.light12.BrickColor = BrickColor.new("White")
    end
end)
while wait(5) do
print(game.workspace.light12.BrickColor)
end

all the printing works but light12 won't change color. Why is that?

0
Any error messages? (Also capitalize the "w" in workspace) Jexpler 63 — 4y
0
It's because you're trying to compare a brickcolor value with string at line 6. Replace the string with BrickColor.new("Black") ScuffedAI 435 — 4y

1 answer

Log in to vote
-1
Answered by
0_2k 496 Moderation Voter
4 years ago
Edited 4 years ago

You have a deb variable but not putting it to use, so remove it or use it.

local click = script.Parent.ClickDetector

click.MouseClick:Connect(function()
    script.Parent.BrickColor = BrickColor.new("Black")
    workspace.light12.BrickColor = BrickColor.new("White")
    wait(1)
end)

while wait(5) do
    print(game.workspace.light12.BrickColor)
end

0
-1 this doesn't solve the question as well as you didn't clean the code up; You should have noticed that the conditional statement is pointless as he sets it to Black only to check if it's black again. BlackOrange3343 2676 — 4y
0
Gotcha and revised 0_2k 496 — 4y
Ad

Answer this question