✓ Accepted answer
So the problem with using BrickColors is that the random function only chooses a random color from all the colors. So what I put those colors into a table and had a random function choose the index instead, then it would assign the color chosen to the part. I also added a debounce for your touched event for you.
local colorPart = script.Parent
local debounce = true
local colors = {Color3.fromRGB(0, 97, 255), Color3.fromRGB(165, 0, 255), Color3.fromRGB(0, 225, 255)}
local function editColors(index, color)
colors[index] = Color3.fromRGB(color)
end
local function addColor(color)
colors[#colors+1] = Color3.fromRGB(color)
end
local function removeColor(index)
table.remove(colors,index)
end
colorPart.Touched:Connect(function()
if debounce then
debounce = false
local x = math.random(1,3)
colorPart.Color = colors[x]
end
wait(1)
debounce = true
end)
I have tested this, it does work, and if it solves your problem, then please mark it as the accepted answer.
Also, I just picked random rgb values that came close to the colors you specified, if they aren't exactly what you want you can tweak them, and I recommend using this tool to help you pick the colors.
2 comments
I tested this too, it also works and in fact I would use this instead, thank you.
I kind of wrote this a bit sloppy, so I'll see if I can also add a way to make it easier to add and remove the colors from the "colors" table.