You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Every time a part joins a folder, it will receive a highlight with a color. However, there can’t be more than one of the same color. So, the part will receive a different color that hasn’t been taken yet. -
What is the issue? Include screenshots / videos if possible!
There are more than one of the same color
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried looking through the documentations that Roblox and the devforum to see how I can userepeat until
, but I couldn’t figure out how to use it. I also tried to usefor loops
but I’m not the best at it.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local folder = script.Parent
local highlightColors = {
Color3.fromRGB(255, 70, 70), -- Red
Color3.fromRGB(255, 110, 70), -- Orange
Color3.fromRGB(255, 200, 70), -- Yellow
Color3.fromRGB(70, 255, 70), -- LightGreen
Color3.fromRGB(70, 70, 255), -- Blue
Color3.fromRGB(70, 225, 255), -- LightBlue
Color3.fromRGB(125, 70, 255), -- Purple
Color3.fromRGB(255, 70, 255) -- Pink
}
local usedColors = {}
local function assignHighlightColor(part)
local randomChance = math.random(1, #highlightColors)
local randomColor = highlightColors[randomChance]
local highlight = Instance.new("Highlight", part)
if randomColor == usedColors then
assignHighlightColor(part)
table.insert(usedColors, randomColor)
else
highlight.FillColor = randomColor
highlight.OutlineColor = randomColor
usedColors[randomColor] = true
end
end
folder.ChildAdded:Connect(function(addedPart)
assignHighlightColor(addedPart)
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.