Trying to make a hair combo giver, but it only gives one hair

I’m trying to work on a homestore, and I’m trying to make a section that has UGC hair combos. I’ve managed to make some mannequins & figured out how to sell them properly + how to remove existing hats.

I’m trying to make it so that when a player clicks on the hairs, it makes them wear all of the hairs on the mannequin.

Attatched is a picture of said mannequin:

And here’s the code (Which I took from a free model hat giver which works) which is copied into each of the handles/hitboxes:

debounce = true



function onTouched(hit)
	if (hit.Character:findFirstChild("Humanoid") ~= nil and debounce == true) then
		debounce = false
		local h = Instance.new("Hat")
		local p = Instance.new("Part")
		h.Name = script.Parent.Parent.Name
		p.Parent = h
		p.Position = hit.Character:findFirstChild("Head").Position
		p.Name = "Handle" 
		p.formFactor = 0
		p.Size = Vector3.new(0,0,0) 
		p.BottomSurface = 0 
		p.TopSurface = 0 
		p.Locked = true 
		script.Parent.SpecialMesh:clone().Parent = p
		h.Parent = hit.Character
		h.AttachmentPos = Vector3.new(0,0,0)
		wait(5)
		debounce = true
	end
end



script.Parent.ClickDetector.MouseClick:Connect(onTouched)

When I click this, it only gives one hair and not all of them. How do I make it so it wears all 3 at once?

so you are clicking the hair right?
if you are then the hitbox of 1 hair overrides the other hitboxes for the clickdetector
if you are willing to use the buttons it would be better
perhaps show us the model that has the buttons and replace the scripts to be there

1 Like

if you want the mannequin to give a player the hair combo it has then you should remove all the Scripts and ClickDetectors inside each hair accessory and then add a ClickDetector and a Script in the “HairMannequin” model.

Script should look something like this:

local mannequin = script.Parent

local clickDetector = mannequin.ClickDetector

local function RemoveHeadAccessories(char:Model)
	for _, v in pairs(char:GetDescendants()) do
		if v:IsA("Accessory") then
			local handle = v.Handle
			local attachment = handle:FindFirstChild("HatAttachment") or handle:FindFirstChild("HairAttachment")
			if attachment then
				v:Destroy()
			end
		end
	end
end

local function OnClick(plr:Player)
	local char = plr.Character
	local humanoid = char:FindFirstChild("Humanoid")
	RemoveHeadAccessories(char)
	
	for _, v in pairs(mannequin:GetChildren()) do
		if v:IsA("Accessory") then
			local accessory = v:Clone()
			accessory.Handle.Anchored = false
			humanoid:AddAccessory(accessory)
		end
	end
end

clickDetector.MouseClick:Connect(OnClick)
1 Like