Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make each players brick a different color?

Hi, I have made a hat for each player to get. I was wondering how would I go about giving each player a random color? Let me explain more. I made it so I can change the color of the hat. How would I make a script that will change the players hat so each one has a diffrent color? I want to make it so that I can control when they change color. I know I would use BrickColor.random Thanks, Antux

1 answer

You could use a list of BrickColors then remove the BrickColors used:-

-- the list of brick colours
local brickColors = {
	BrickColor.Black(),BrickColor.Blue(), BrickColor.DarkGray()
}

for i=1, #brickColors  do
	local ran = math.random(#brickColors)
	print(brickColors[ran])
	brickColors[ran] = nil -- remove from the list
end

This is just an example but there are many different ways to do this. The example will remove only work once as the items are removed, to fix this you could make a clone of the table.

Hope this helps.

This discussion is preserved as it was. New answers, comments, and votes are closed.