I am trying to make the next button go through the hairs in order without making a function for each hair, and the only one that actually clones is the last one even though it seems like they all work, and there is no error, any help would be great.
All my variables and items are in the correct place too, I just don't want to post all my code because it's like 300 lines.
Code:
local hair = {
[1] = game:GetService("ReplicatedStorage"):WaitForChild("Hair"):WaitForChild("Beautiful");
[2] = game:GetService("ReplicatedStorage"):WaitForChild("Hair"):WaitForChild("Long Straight");
[3] = game:GetService("ReplicatedStorage"):WaitForChild("Hair"):WaitForChild("Long Puffy");
}
nextHair.MouseButton1Click:Connect(function()
curHair = curHair + 1
if (curHair > maxHair) then
curHair = minHair
end
for i,v in pairs(hair) do
for j,k in pairs(char:GetChildren()) do
if (k:IsA("Accessory")) then
k:Destroy()
end
end
if (i == curHair) then
local clone = v:Clone()
clone.Parent = char
print("Hair: " .. clone.Name)
end
end
end)

3 comments
Printing it works fine for me too, but it only clones 1 hair, even though in the output it says it's working
It's supposed to only clone 1 hair because in your script it's Destroy()ing the others
Oh I see, move your second For loop out and above the For loop it's currently in