Hello. I am trying to make a script which removes all accessories after the player joins the game.
I made this script but i realised that this will delete everything inside the character but the script didnt work either way so.
game.Players.PlayerAdded:Connect(function(plr)
for index, child in pairs(plr.Character:GetChildren()) do
child:Destroy()
end
end)
``
So how do i make this script work the way i requested above?
game.Players.PlayerAdded:Connect(function(plr)
local character = player.Character or player.CharacterAdded:Wait()
for index, child in pairs(plr.Character:GetChildren()) do
if child:IsA("Accessory") then
child:Destroy()
end
end
end)
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(character)
for index, child in pairs(plr.Character:GetChildren()) do
if child:IsA("Accessory") then
child:Destroy()
end
end
end)
end)
That way it will probably work as intended too, btw i recommend you changing plr.Character inside pairs() to character just for better code organization.