Well, this got moderated for being too vague last time, so hopefully I can word it a bit better...
I want to create a weird sort of... Aura system, for use in anime games like Bleach or Dragon Ball. But I want to ensure that each player has a totally unique aura colour, for reasons I'll go into later for the sake of brevity.
To accomplish this, I'm essentially just going to toss a vector3 value into the player's client or their character or somewhere, and have any aura particle effects read it to determine their colour; if the value is 0, 0, 0, the player will have an aura particle emitter in their torso whose colour value is 0,0,0.
So, now I've got a system where I can freely change the aura colour of a person. Brilliant. But like I said, I want to ensure that each one is unique, so my idea was to generate them based on playerID, as each player has their own ID number. So is there any way to actually accomplish this? The only thing I've thought of is using maths, like...
playerID = game.Players.LocalPlayer.UserId character = game.Players.LocalPlayer.Character function gencolor() local VectorColor = Instance.new(Vector3Value) VectorColor.Parent = character.Torso local value1 = playerID - [insert some arbitrary long number here] local value2 = playerID - [insert some arbitrary long number here] local value3 = playerID - [insert some arbitrary long number here] if value1 >255 then 1 = 255 if value2 > 255 then 2 = 255 if value3 > 255 then 3 = 255 VectorColor.Value = Vector3.new(1 , 2 , 3) end
Or something along those lines. But then as new players arrive to play the game, they'd find that they all have pure white auras as the number subtracted from their value is too small.
If this isn't an option, is there any way to easily generate unique colours on a player-by-player basis?
The reason that I want every player to have a unique colour assigned to them is so that you can almost identify a person from long range based on the colour or "feel" of their aura alone. Two people might have similar colours, but no two will be identical.
I don't know what procedural means to you, but procedural generation simply means that data is generated by an algorithm rather than being predetermined. This algorithm can be the algorithm for a pseudorandom number generator, perlin noise, or even some obscure algorithm that just gets the magnitude of the vertex over the lips.
Perlin noise will always generate the same values, given the same input. This is because the generator is functional. An example of how to use it in this context might for example be
Color.Value = Color3.fromHSV(math.noise(UserId*10,UserId,UserId*.001),1,1)
HSV is used in this context to give a full range of colours from a simple algorithm.
Because the random generator can take a seed, and will always generate the same sequence of numbers from the seed, you can use the UserId as the seed.
math.randomseed(UserId) Color.Value = Color3.new(math.random(), math.random(), math.random())
Similar UserIds will produce similar colours in this case however, so you may want to test whether the numbers produced are diverse enough for your playerbase.
This generates the colour randomly based on when they joined, and this will not produce the same colours every time a player joins so you will need to save their colour in a DataStore. I am simply leaving this here for completeness.
Color.Value = Color3.fromHSV(tick()%1,1,1)
Alternatively, you can use the fractional part of the tick to seed the random number generator
math.randomseed((tick()%1)*1e16) Color.Value = Color3.new(math.random(), math.random(), math.random())
However as mentioned you will need to save this.