This script is made to override the character and delete the player's accessories. Here's my code:
local player = game.Players:GetPlayerFromCharacter(script.Parent) local character = player.Character local character_children = character:GetChildren() --:ClearCharacterAppearance() character:WaitForChild("ForceField") character.ForceField:Destroy() local hats = character:FindFirstChildWhichIsA("Accessory") hats:Destroy() --This is where I want to remove the hats, which it doesn't character.Head.Transparency = 1 character.Torso.Transparency = 1 character["Left Arm"].Transparency = 1 character["Right Arm"].Transparency = 1 character["Left Leg"].Transparency = 1 character["Right Leg"].Transparency = 1 character.Sound:Destroy() character.Head.face:Destroy() character.Humanoid.JumpPower = 0 character.Humanoid.CameraOffset = Vector3.new(0, 10, 0)
I tried this: game.Players.LocalPlayer:ClearCharacterAppearance()
and it doesn't get rid of the accessories.
What do I do!?
Looking at the code's hierarchy, it looks like this is being done inside a LocalScript
. If you intend the accessories to be deleted across every player's game, then using a regular server Script
will be the way to go.
Anyway, to answer your question, I have gone into studio and cleaned up your script. Basically, it searches the character and deletes any accessory or face, then changes all the parts in the character to become invisible.
wait(1/2) local char = script.Parent local characterPart = script.Parent:GetDescendants() for a = 1, #characterPart do if characterPart[a]:IsA("BasePart") then characterPart[a].Transparency = 1 elseif characterPart[a]:IsA("Accessory") or characterPart[a].ClassName == "Decal" then characterPart[a]:Destroy() end end char.Sound:Destroy()
Or you can ignore all that and instead go to StarterPlayer.LoadCharacterAppearance
and set it to false.
There is a function in Humanoid called RemoveAccessories()
player.Character.Humanoid:RemoveAccessories() -- Will remove all accessories the player has equipped.
I hope this helps!
local player = game.Players:GetPlayerFromCharacter(script.Parent) local character = player.Character local character_children = character:GetChildren() for i,v in pairs(character_children) do if v:IsA("Accessory") then v:Destroy() end end
and then add the other things of ur script into this
i have it like this in my teleport service to transparence the parts but u can say when found part:destroy() to destroy them or with part.Parent = place to move them or with local copy = part :Clone() to clone them and then copy.Parent = placetomove to move the copy
for _, part in pairs(player.Character:GetChildren()) do --for each of the objects in the character, if part:IsA("MeshPart") or part:IsA("BasePart") or part == "Head" then --check if it's a part, and if so if part.Name ~= "HumanoidRootPart"then part.Transparency = transparency else part.Transparency = 1 end --set its transparency end if part:IsA("Accessory") then --<-- this part u looking for for _, part in pairs(part:GetChildren()) do if part:IsA("Part") then part.Transparency = transparency end end end end