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

Why doesn't this script get all of the children in the player and only delete the accessories?

Asked by 5 years ago

this script is supposed to fetch the player and then get all of the accessories in the player and delete them. The script is a regular script in SSS.

game.Players.PlayerAdded:Connect(function(p)
    p.CharacterAdded:Connect(function(char)
        if p.leaderstats["Time Played"].Value >= 100 then
            local children = char:GetChildren()
        for i = 1, #children do
            if (children[i].className == "Accessory") then
                children[i]:Remove()
            end
        end
        end
    end)
end)

1 answer

Log in to vote
-1
Answered by 5 years ago
Edited 5 years ago

Try this:

game.Players.PlayerAdded:Connect(function(p)
  p.CharacterAdded:Connect(function(char)
    wait(1) --wait for accessories to load (if any)
    local humanoid = char:WaitForChild("Humanoid")
    if p.leaderstats["Time Played"].Value >= 100 then
      humanoid:RemoceAccessories()
    end
  end)
end)
Ad

Answer this question