Weird error with click detectors

Hello all! My issue is with a click to change color part.
So here is my code:

local material = Enum.Material.Glacier
local cyan = Color3.new(0.333333, 1, 1)
function onClick(playerWhoClicked)
	part.Color = cyan
	part.Material = material
end

script.Parent.ClickDetector.MouseClick:connect(onClick)

Now my issue is that when I click the part it changes to black and then to cyan?
Is this is an issue with the properties? Anyone know what to do?

Hello, could you please give more information on what the object is? Are you trying to change the material and color of a part when clicked?

local part = script.Parent
local material = "Ice"
local cyan = BrickColor.new("Cyan")
function onClick(playerWhoClicked)
	part.BrickColor = cyan
	part.Material = material
end

script.Parent.ClickDetector.MouseClick:connect(onClick)

There is no material in a part called glacier.

Thanks! There was an issue with the variable in my script, but yours worked good! Thanks!

1 Like