Hello, I have managed to make the part change colors when you click it but am not able to make it so when you click it a random time, if you get the color you need the ClickDetector will be destroyed.
Could you provide the script you’re attempting to use to achieve this? We would be able to diagnose your problem better and give you reasoning on why!
script.Parent.ClickDetector.MouseClick:Connect(function()
script.Parent.BrickColor = BrickColor.Random()
if BrickColor.new(“Forest green”) then
script.Parent.ClickDetector:Destroy
end)
I have this but can’ make it get destroyed
Ah, alright. An example of destroying a part when it’s a certain color would be:
if script.Parent.BrickColor.Name == "Forest green" then
script.Parent.ClickDetector:Destroy()
end
There are a lot of BrickColor values, it’s possible the one you’re attempting to match won’t be randomly selected.
True…true… then how would I make it be a selected few that would be random.
A simple way would be to check if the BrickColor’s name contains a particular color.
if part.BrickColor.Name:lower():match("red") then
part:Destroy()
end