Hey i came on here today because i dont know why there is more then 1 things in the table.
local function shuffleColors()
for Index = 1, #CharactersFolder do
RandomIndex = CharactersFolder[math.random(1, #CharactersFolder)]
if not table.find(ShuffledTable, RandomIndex) then
table.insert(ShuffledTable , RandomIndex)
end
end
return RandomIndex
end
here is the code (inside the charactersfolder is just values)
basically i want each player that joins the game to get a random color but if he gets a color randomly that another player in the game has then it would just pick another random color. and when they leave the game there color will be removed from the table (hopefully this makes sense and i do this all with that functionh)
local ColorTable = {}
local PlayerColors = {}
local function PickColor(Player)
if #ColorTable == 0 then return end
local num = math.random(#ColorTable)
local Color = ColorTable[num]
table.remove(ColorTable, num)
PlayerColors[Player] = Color
return Color
end
local function PlayerRemoving(Player)
if PlayerColors[Player] then
table.insert(ColorTable, PlayerColors[Player])
PlayerColors[Player] = nil
end
end