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

Group only hat remover?

Asked by 5 years ago

I've been having trouble with this script, i want to make it so your hats will only remove if you're in a certain group on roblox, here is the script. Anyone who is not in that group will have their hat remain.

exclusion = {49207141}

function RemoveAccessories(character) character:WaitForChild("Head") local player = game.Players:GetPlayerFromCharacter(character) for i,v in ipairs(exclusion) do if player.UserId == v then return end end repeat wait(1) until (player:HasAppearanceLoaded()==true) wait(1)

local childs = character:GetChildren()
for i,v in ipairs(childs) do
    if v:IsA("Accessory") or v:IsA("CharacterMesh") or v:IsA("ShirtGraphic") then
        v:Destroy()
    end
end
local headMesh = character.Head:FindFirstChild("Mesh")
if not (headMesh and headMesh:IsA("SpecialMesh")) then
    headMesh = Instance.new("SpecialMesh")
    headMesh.Name = "Mesh"
    headMesh.Parent = character.Head
end
headMesh.MeshType = "Head"
headMesh.Scale = Vector3.new(1.25,1.25,1.25)
wait(60)
--Second pass
childs = character:GetChildren()
for i,v in ipairs(childs) do
    if v:IsA("Accessory") or v:IsA("CharacterMesh") or v:IsA("ShirtGraphic") then
        v:Destroy()
    end
end
headMesh = character.Head:FindFirstChild("Mesh")
if not (headMesh and headMesh:IsA("SpecialMesh")) then
    headMesh = Instance.new("SpecialMesh")
    headMesh.Name = "Mesh"
    headMesh.Parent = character.Head
end
headMesh.MeshType = "Head"
headMesh.Scale = Vector3.new(1.25,1.25,1.25)
wait(60)

end

game.Players.ChildAdded:Connect(function(player) player.CharacterAdded:Connect(RemoveAccessories) end)

Answer this question