im trying to change the part color everytime you click it. it goes in order of pink, blue, red, green, and then back to pink. i dont know why this wont work? Nothing is in the output.
local click = script.Parent.ClickDetector partcolor = script.Parent.BrickColor local sound = script.Parent.Beep click.MouseClick:connect(function() if partcolor == "255, 0, 191" then sound:Play() partcolor = "0, 0, 255" end if partcolor == "0, 0, 255" then sound:Play() partcolor = "255, 0, 0" end if partcolor == "255, 0, 0" then sound:Play() partcolor = "0, 255, 0" end if partcolor == "0, 255, 0" then sound:Play() partcolor = "255, 0, 191" end end)
please help, thank you
.BrickColor
can't be assigned to a string value, instead you can do a BrickColor.new()
value so when you set partcolor
, for example on line 8 it could be partcolor = BrickColor.new(0,0,255)
. The final code would be:
local click = script.Parent.ClickDetector partcolor = script.Parent.BrickColor local sound = script.Parent.Beep click.MouseClick:connect(function() if partcolor == BrickColor.new(255, 0, 191) then sound:Play() partcolor = BrickColor.new(0,0,255) end if partcolor == BrickColor.new(0, 0, 255) then sound:Play() partcolor = BrickColor.new(255, 0, 0) end if partcolor == BrickColor.new(255, 0, 0) then sound:Play() partcolor = BrickColor.new(0, 255, 0) end if partcolor == BrickColor.new(0, 255, 0) then sound:Play() partcolor = BrickColor.new(255, 0, 191) end end)
I hope this helped! If this did solve your problem might you select this as the answer, Thanks!