Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why wont the hair clone into the players character?

Asked by 5 years ago
Edited 5 years ago

I have no errors, but in my game the hair thats supposed to be cloned won't clone. I dont see any issues with Values and nothing with the names of hats in playerList.

local rs = game.ReplicatedStorage
local hairList = rs.HairList

game.Players.PlayerAdded:Connect(function(plr)

local SetHair = Instance.new("StringValue")
    SetHair.Name = "Hair"
    SetHair.Value = "Bald"
    SetHair.Parent = plr

    -- Loading Data

    local success, result = pcall(function()
        Storage:GetAsync(plr.UserId)
    end)

    if not success then
        warn(result)
    else
        local LoadArray = Storage:GetAsync(plr.UserId)
        if LoadArray then
            hasCharacter.Value = LoadArray[1]
            SetHair.Value = LoadArray[2]
        end
    end

plr.CharacterAdded:Connect(function(character)

local hairFound = hairList:FindFirstChild(SetHair.Value)
    if hairFound then
        hairFound:Clone().Parent = character -- Clone here.
    end

end)

2 answers

Log in to vote
1
Answered by
iXBruv 24
5 years ago

character.Humanoid:AddAccessory(hairFound:Clone()) should be used instead of cloning and setting the parent to the character

0
If it is still not calling for the hair you may also be right with your first answer iXBruv 24 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

The Array doesn't load in time for when the cloning starts making the script think the SetHair is "Bald". All I need to do is add a wait()

Answer this question