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

Why doesn't the hat remover work in R6?

Asked by 4 years ago
Edited 4 years ago

I had a hat remover working in my game but when I changed it to R6, the hat remover stopped working so I tried to make a new one but nothing seemed to work. Can someone help me by pointing out what I've done wrong? There are no errors in the output bar.

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        local c = char:GetChildren()
        if c.ClassName == "Accessory" then
            c:Destroy()
            c:Remove()
        end
    end)
end)

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

You didn't enumerate through the assets of the Character, meaning you couldn't locate every Accessory to properly remove them. You also tried to call methods of Instance on an array, as :GetChildren() return a table.

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        local Accessories = Character:GetChildren()
        for _,Accessory in pairs(Accessories) do
            if (Accessory:IsA("Accessory")) then
                Accessory:Destroy()
            end
        end
    end)
end)
0
The script still doesn't work. Nothing in the output bar either. SuperFarter98 5 — 4y
Ad

Answer this question