while true do wait(0.1) local w = game.Workspace:GetChildren() for i = 1, #w do c = w[i]:GetChildren() for i=1, #c do if (c[i].className == "Shirt Graphic") then c[i]:remove() end end end end
I recently made this script but it doesn't seem to work. What have I done wrong?
I would suggest using the DescendantAdded event, as well. This is a useful event that triggers whenever a child is added to the object or any of its children! You can hook up a function that destroys an object if it is a ShirtGraphic with this event.
Here's an example...
workspace.DescendantAdded:connect(function(object) -- hook up to the descendantadded event in workspace wait(0.03) -- avoid running into issues with attempting to set the parent to nil when you immediately destroy something in a function hooked to an event listening for added children if object and object.ClassName == "ShirtGraphic" then -- check if the object exists and is a shirtgraphic object:Destroy() -- destroy the object end end)
The class name is called Shirt not ShirtGraphic.
workspace.DescendantAdded:connect(function(object) -- hook up to the descendantadded event in workspace wait(0.03) -- avoid running into issues with attempting to set the parent to nil when you immediately destroy something in a function hooked to an event listening for added children if object and object.ClassName == "Shirt" then -- check if the object exists and is a shirtgraphic object:Destroy() -- destroy the object end end)