I am making a charactercreations screen, like so;
Basically when you click ‘male’ the hair options for male appears on the hair choices later, one by one, via a table, for female, same thing.
I am having trouble with the actual hair choices option. Here is the table that I am using;
local HairChoices = {
MaleHairs = {
["Bald"] = nil;
["Trecky Hair"] = 32278814;
["Afro"] = 5100703261;
["Blowout"] = 5269022822;
["Edgar Cut"] = 12654750434;
["Medium Fade"] = 4584980640;
["Middle Part"] = 7097720734
};
FemaleHairs = {
["Bald"] = nil;
["Popstar Hair"] = 5890690147;
["Black High Ponytails"] = 13413181958;
["Wavy Side Part w/ edges"] = 6346367086;
["Pigtails"] = 5769262031;
["Wavy Ponytail"] = 6238509303;
["Messy Buns"] = 10690181802
}
}
Here is the function that updates the hair choices, which gives the dummy their hair using InsertService
local function updateHairSelection()
if not ClickedMale and not ClickedFemale then return end
print("Player has clicked one or the other")
-- Update the hair selection based on the currentIndex
local currentHair = nil
if ClickedMale then
print("player has clicked male, showing male hairs")
currentHair = HairChoices.MaleHairs[currentIndex.MaleHairs]
return currentHair
elseif ClickedFemale then
print("player has clicked female, showing female hairs")
currentHair = HairChoices.FemaleHairs[currentIndex.FemaleHairs]
return currentHair
end
-- Do something with the currentHair value, like updating an image or text label in the frame
-- Insert the hair accessory on a dummy
local dummy = game:GetService("InsertService"):LoadAsset(currentHair)
local hair = dummy:FindFirstChildWhichIsA("Model"):FindFirstChildWhichIsA("Accessory")
if hair then
hair.Parent = CharDummy -- Change "script.Parent" to the location where you want to place the hair accessory
end
end
Whenever you click on the arrow, it’ll go to the next hair, destroying the previous one, and adding the new one, however here is the problem:
-
It is NOT even adding the accessory, despite having the correct asset id, which I have tested out beforehand using the commandbar
-
The textlabel that is meant to show the choice names for the hair doesn’t even give the name, like it’s supposed to give, “Trecky Hair”, it just puts in a number
Here is the rest of the code
RightArrow.MouseButton1Click:Connect(function()
if ClickedMale then
currentIndex.MaleHairs = currentIndex.MaleHairs + 1
HairChoiceLabel.Text = currentIndex.MaleHairs
updateHairSelection()
if currentIndex.MaleHairs > #HairChoices.MaleHairs then
currentIndex.MaleHairs = 1
end
elseif ClickedFemale then
currentIndex.FemaleHairs = currentIndex.FemaleHairs + 1
HairChoiceLabel.Text = currentIndex.FemaleHairs
updateHairSelection()
if currentIndex.FemaleHairs > #HairChoices.FemaleHairs then
currentIndex.FemaleHairs = 1
end
end
end)
LeftArrow.MouseButton1Click:Connect(function()
if ClickedMale then
currentIndex.MaleHairs = currentIndex.MaleHairs - 1
HairChoiceLabel.Text = currentIndex.MaleHairs
updateHairSelection()
if currentIndex.MaleHairs < 1 then
currentIndex.MaleHairs = #HairChoices.MaleHairs
end
elseif ClickedFemale then
currentIndex.FemaleHairs = currentIndex.FemaleHairs - 1
HairChoiceLabel.Text = currentIndex.FemaleHairs
updateHairSelection()
if currentIndex.FemaleHairs < 1 then
currentIndex.FemaleHairs = #HairChoices.FemaleHairs
end
end
end)
Here is a video on how it is working currently
Any help would be appreciated