Hello! A friend and I are making a game, and inside is a random avatar generator. It generates eyes, a mouth, a skin color from the list and random leg and torso colors. However, when the game is started, the face part does not function.
We both already know that the faces do display and have not been taken down. My friend made a script that worked, however it used a bunch of if statements and it just wasn’t ideal. Here is the code.
local randomeyes = math.random(1,11)
local randommouth = math.random(1,11)
local randomsc = math.random(1,13)
local sctable = {BrickColor.new("Bright orange"), BrickColor.new("Steel blue"), BrickColor.new("Sand green"), BrickColor.new("Daisy orange"), BrickColor.new("Bright yellow"), BrickColor.new("Medium stone grey"), BrickColor.new("Pastel Blue"), BrickColor.new("Dark green"), BrickColor.new("Bright green"), BrickColor.new("Brick yellow"), BrickColor.new("Carnation pink"), BrickColor.new("Institutional white"), BrickColor.new("Persimmon")}
local etable = {"rbxassetid://8490553519", "rbxassetid://8490867175", "rbxassetid://8490845222", "rbxassetid://8490767522", "rbxassetid://8490638841", "rbxassetid://8490609474", "rbxassetid://8490885723", "rbxassetid://8490821161", "rbxassetid://8490794759", "rbxassetid://8490672508", "rbxassetid://8490737868"}
local mtable = {"rbxassetid://8490637538", "rbxassetid://8490554496", "rbxassetid://8490844517", "rbxassetid://8490867821", "rbxassetid://8490766940", "rbxassetid://8490608807", "rbxassetid://8490886264", "rbxassetid://8490820456", "rbxassetid://8490795435", "rbxassetid://8490673442", "rbxassetid://8490736895"}
local mouth = script.Parent.Head.Mouth.Texture
local eyes = script.Parent.Head.Eyes.Texture
local person = script.Parent
local tcolor = BrickColor.Random()
local lcolors = BrickColor.Random()
-- random eye generation
for i = 1,11,1 do
if i == randomeyes then
eyes = etable[randomeyes]
end
end
-- random mouth generation
for i = 1,11,1 do
if i == randommouth then
mouth = mtable[randommouth]
end
end
-- random skin generation
for i = 1,13,1 do
if i == randomsc then
local sc = sctable[randomsc]
person.Head.BrickColor = sc
person["Left Arm"].BrickColor = sc
person["Right Arm"].BrickColor = sc
person.Torso.BrickColor = tcolor
person["Left Leg"].BrickColor = lcolors
person["Right Leg"].BrickColor = lcolors
person.Helmet.Handle.BrickColor = lcolors
end
end
-- end of script, time to destroy
script:Destroy()
Output displays the numbers just fine when printing, so we know the code works.
As always, help would be appreciated!