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

Randomly generated hair, can someone help me ?

So what i did is a humanoid that's randomly generated. And i need to make the hair randomly generated, but the problem is that the mesh is separated from the texture and i need to find a way to keep them together.

Here is what i have in mind for the script :

Groups ("mesh of the hair1", "texture of the hair1") name : hair1

Groups ("mesh of the hair2", "texture of the hair2") name : hair2

Groups ("mesh of the hair3", "texture of the hair3") name : hair3

Groups ("mesh of the hair4", "texture of the hair4") name : hair4

Groups ("mesh of the hair5", "texture of the hair5") name : hair5

local random = {"hair1", "hair2", "hair3", "hair4", "hair5"} -- Shirt Selection

script.Parent.i dunno = "rbxassetid://"..random[math.random(1,#random)] -- Picks one of the 4 shirts

-- Shoutouts to Daemonophobia

If someone could transform this to a correct script, it would be nice.

1 comment

0

Does my answer solve it?

1 answer

You could do something like this:

local Hairs = {
["Hair1"] = {Texture = "", Name = "Hair1"};
["Hair2"] = {Texture = "", Name = "Hair2"};
["Hair3"] = {Texture = "", Name = "Hair3"};
["Hair4"] = {Texture = "", Name = "Hair4"};
["Hair5"] = {Texture = "", Name = "Hair5"};
}

local keys = {}
for key, _ in pairs(Hairs) do
    table.insert(keys, key)
end

local randomKey = keys[math.random(#keys)]
local Rand = Hairs[randomKey]
local texture = Rand.Texture
local Name = Rand.Name

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