Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

This T-Shirt remove script isn't working?

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?

2 answers

✓ Accepted answer
  1. I believe that className should be ClassName (is probably case-sensitive).
  2. The ClassName would be "ShirtGraphic", not "Shirt Graphic". See this for more information.

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)

3 comments

0

Still not working...any other ideas?

0

Are you using my variant? Are you sure you copied it correctly? Are you using online mode or testing with a server (like you should be instead of Play Solo)? I just ran it through Studio and it appears to work fine...

0

Oh my bad, I was Playing Solo. It works just fine, thanks!

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)

1 comment

0

No, Shirt destroys the entire shirt of the player. I just want the T-Shirt to be destroyed.

This discussion is preserved as it was. New answers, comments, and votes are closed.