Is there a "Randomize my array" function?

So in my game I want to randomize some player colors. There is a list of 4 colors I set up and I want to assign a player a random color. The problem is I want to assign each player a different color. Thinking about this in general programming terms I want to scramble or randomize an already existing array or at least the indices into an array without duplicates. Does this exist some how?

The only way I figured I could do this myself is to do a loop to get a random number between 0-array length and insert it into another array (if I did not already pull that random number already)… but this seems insufficient.

Ok so each index in the array has a color?

If so then just randomize which index they will use from the array.

OK. I don’t think you read my question. If I have 4 colors and want to randomize what color each player has then I can easily run into 2 players grabbing the same color.

Weird the second paragraph wasn’t there earlier.
ok then you could create a temp variable to check against for each player.

now one possible thing you could look into is random stream.

https://docs.unrealengine.com/latest/FRA/Engine/Blueprints/UserGuide/RandomStreams/index.html

I will just add that TArray does not have any shuffle functions

Why not remove the color from the array after it has been assigned to a player?

There are a few ways to randomize arrays though if you really want to go that route. You just have a multiple arrays which then randomly trade indexes and output a final scrambled array. Kind of like mixing drinks.

This would do the trick