Hello, i am currently working on random color selection for each class.
Here is my code:
local RandomColors = {Color3.fromRGB(255, 89, 89),Color3.fromRGB(248, 217, 109),
Color3.fromRGB(9, 137, 207),Color3.fromRGB(207, 142, 50),Color3.fromRGB(99, 95, 98),
Color3.fromRGB(91, 154, 76),Color3.fromRGB(255, 148, 148),Color3.fromRGB(255, 102, 204),
Color3.fromRGB(0, 143, 156)
}
local MadeColors = {}
for i, GamePiece in pairs(FolderToCheck:GetChildren()) do
local AtColor = Color3.fromRGB(0,0,0)
local FoundItem = table.find(MadeColors,GamePiece.Name)
print(FoundItem) -- always prints nil
if FoundItem then
AtColor = MadeColors[table.find(MadeColors,GamePiece.Name)]
else
local RandomNewColor = RandomColors[math.random(1,#RandomColors)]
MadeColors[GamePiece.Name] = RandomNewColor
table.remove(RandomColors,table.find(RandomColors,RandomNewColor))
AtColor = RandomNewColor
print(MadeColors,GamePiece.Name)
end
end
-- There are multiple parts with the same name, thats why i add it to table.
for i, GamePiece in pairs(FolderToCheck:GetChildren()) do
local AtColor = Color3.fromRGB(0,0,0)
local FoundItem = table.find(MadeColors,GamePiece.Name)
print(FoundItem) -- always prints nil
if FoundItem then
AtColor = MadeColors[table.find(MadeColors,GamePiece.Name)]
else -- look here
local RandomNewColor = RandomColors[math.random(1,#RandomColors)]
MadeColors[GamePiece.Name] = RandomNewColor -- and here
table.remove(RandomColors,table.find(RandomColors,RandomNewColor))
AtColor = RandomNewColor
print(MadeColors,GamePiece.Name)
end
end
local RandomColors = {Color3.fromRGB(255, 89, 89),Color3.fromRGB(248, 217, 109),
Color3.fromRGB(9, 137, 207),Color3.fromRGB(207, 142, 50),Color3.fromRGB(99, 95, 98),
Color3.fromRGB(91, 154, 76),Color3.fromRGB(255, 148, 148),Color3.fromRGB(255, 102, 204),
Color3.fromRGB(0, 143, 156)
}
local MadeColors = {}
for i, GamePiece in pairs(FolderToCheck:GetChildren()) do
local AtColor = Color3.fromRGB(0,0,0)
local FoundItem = MadeColors[GamePiece.Name]
print(FoundItem) -- always prints nil
if FoundItem then
AtColor = FoundItem
else
local RandomNewColor = RandomColors[math.random(1,#RandomColors)]
MadeColors[GamePiece.Name] = RandomNewColor
table.remove(RandomColors,table.find(RandomColors,RandomNewColor))
AtColor = RandomNewColor
print(MadeColors,GamePiece.Name)
end
end
-- There are multiple parts with the same name, thats why i add it to table.