player.Character:WaitForChild("Shirt") if player.Character:FindFirstChild("Shirt") then player.Character.Shirt:Destroy() end if player.Character:FindFirstChild("Pants") then player.Character.Pants:Destroy() end if player.Character:FindFirstChild("ShirtGraphic") then player.Character.ShirtGraphic:Destroy() end
Whenever I run this script without wearing any clothing, I always get
Infinite yield possible on 'DaBrainlessOne:WaitForChild("Shirt")'
any help?
I would rewrite it like this:
for index, child in pairs(player.Character:GetChildren()) do if child:IsA("Clothing") or child:IsA("ShirtGraphic") then child:Destroy() end end
repeat wait() until workspace:FindFirstChild(player.Name) -- waits until the character is a descendant of workspace or loaded --player.Character:WaitForChild("Shirt") -- THIS WONT WORK IF THE PLAYER DOESN'T HAVE A SHIRT, THE SCRIPT WILL CONTINUE TO WAIT UNTIL A SHIRT INSTANCE IS IN THE CHARACTERS MODEL if player.Character:FindFirstChild("Shirt") then player.Character.Shirt:Destroy() else print('No Shirt Detected') end if player.Character:FindFirstChild("Pants") then player.Character.Pants:Destroy() else print('No Pants Detected') end if player.Character:FindFirstChild("ShirtGraphic") then player.Character.ShirtGraphic:Destroy() else print('No Shirt Graphic Detected') end