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

Delete all accessories script not working?

Asked by
niroqeo 123
4 years ago
Edited 4 years ago

Hi, the title explains it. Also, it doesn't print the name of the hats.. It kinda just ignores it.

function getHair(plr, folder, gender)
    print(plr.Name.. " is a ".. gender)
    local hairs = serverStorage.Accessories:FindFirstChild(gender.."Hair")
    local hairChooser = math.random(1, #hairs:GetChildren())
    print(hairChooser)
    local chosenHair = hairs:FindFirstChild(gender..hairChooser)
    chosenHair.Handle.BrickColor = BrickColor.new(colours[math.random(1, #colours)])
    local clone = chosenHair:Clone()
    local clone2 = chosenHair:Clone()
    clone.Parent = folder
    local character = plr.CharacterAdded:Wait(2)
    for i,v in pairs(character:GetChildren()) do
        if v:IsA("Accessory") then
            print(v.Name.." is a hat")
            v:Destroy()
        else
            print(v.Name)
        end
    end
    clone2.Parent = character
    print("finished")
end

0
is it a local or a server script? RAFA1608 543 — 4y
0
you can get a player's character from this: plr.Character RAFA1608 543 — 4y
0
I know. Also, this is a server script. niroqeo 123 — 4y

1 answer

Log in to vote
0
Answered by
niroqeo 123
4 years ago
Edited 4 years ago

Fixed it! All I had to do was use the a for loop properly.

Ad

Answer this question