Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

2 comments

0

Any error messages? (Also capitalize the "w" in workspace)

0

It's because you're trying to compare a brickcolor value with string at line 6. Replace the string with BrickColor.new("Black")

1 answer

✓ Accepted answer

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

2 comments

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.

0

Gotcha and revised

This discussion is preserved as it was. New answers, comments, and votes are closed.