This code is used in a character select menu to chose the hair you want on your character, but when the hair clones it just falls into the void.
local button = script.Parent local function onButtonActivated() game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui') local hair = game.Lighting.Hair.Hair01:Clone() local char = game.Workspace.Intro.Char hair:clone().Parent = char end button.Activated:Connect(onButtonActivated)
You need to attach the hair somehow. I haven't done this myself, but if char is a character with a Humanoid, this might work:
local function onButtonActivated() game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui') local hair = game.Lighting.Hair.Hair01:Clone() local hairClone = hair:Clone() local char = game.Workspace.Intro.Char hairClone.Parent = char char.Humanoid:AddAccessory(hairClone) end
I'm not entirely sure why you would need to clone it twice though, so this could also work:
local function onButtonActivated() game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui') local hair = game.Lighting.Hair.Hair01:Clone() local char = game.Workspace.Intro.Char hair.Parent = char char.Humanoid:AddAccessory(hair) end
Edit: It seems like you might not even need to set the hair's parent, since that seems to be included in the AddAccessory function.
Edit 2: Apparently you can't set its parent before using AddAccessory. Also, this needs to be done in a regular script, not a local script. So if you're using a local script, use a RemoteEvent.
Edit 3: Here is a local script that worked for me:
local Button = script.Parent local function onButtonActivated() game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui') local hair = game.Lighting.Hair.Hair01:Clone() local char = game.Workspace.Intro.Char hair.Parent = char local weld = Instance.new("Weld") weld.Parent = hair.Handle weld.Part0 = hair.Handle weld.Part1 = char.Head weld.C0 = hair.Handle.CFrame weld.C1 = char.Head.CFrame hair.Handle.Position = hair.Handle.Position + Vector3.new(0,0.7,0) end Button.Activated:Connect(onButtonActivated)
I changed the position by 0.7, cause for some reason the hat I tested it with had to be offset that amount. Idk if you're supposed to change the position of the Handle or the Mesh though, but at least it attaches now.