I’m in the process of making a cool character customisation gui for my project.
When you click the button for the hair you want to equip, it destroys the currently existing hair, and gives the new one.
(Hairs are in the ‘Hat’ class. This is to seperate them from the ‘Accessories’ in which I use for helmets and hats.)
However, when I re-assign the parent of the Hair into the character, nothing happens.
There are no errors appearing in the output, and I have tried using Accessories instead of Hats and still no difference.
Here is the code in the “Equip” button:
local armour = script.Parent.Parent.Item.Value
n = 0
script.Parent.MouseButton1Click:Connect(function()
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent
armour = script.Parent.Parent.Item.Value
if n == 1 then
n = 0
if plr.Character:FindFirstChild("Hair") ~= nil then
plr.Character.Hair:Destroy() -- remove existing hair
end
local newhelm = armour:Clone()
newhelm.Name = "Hair"
newhelm.Handle.Transparency = 1
--[[
if the player is wearing a helmet that allows hair to be equipped too:
Make it visible ↓↓
else ↓↓
Make it invisible ↓↓
--]]
if plr.Character:FindFirstChild("Helmet") ~= nil then
if plr.Character.Helmet.RemoveHair.Value == true then
else
newhelm.Handle.Transparency = 0
end
else
newhelm.Handle.Transparency = 0
end
newhelm.Parent = plr.Character -- equip the hair
script.Parent.Parent.Parent.Parent.HairV.Value = newhelm.Name
-- close up the preview frame
script.Parent.Parent.Visible = false
local g = script.Parent.Parent:GetChildren()
for i = 1, #g do
if g[i].Name == "ItemImg" then
g[i]:Destroy()
end
end
wait(1)
n = 1
end
end)
I don’t believe that the code is the problem, but I’m still posting it here.
Reminder: The issue is the Hat is not being equipped onto the player.
Thanks!