How can I make a line of code that detects something and destroys it but only if the something is detected

Exactly as the title states. I’m currently using: workspace:WaitForChild("CharacterCloneDisplay"):Destroy() but if it doesn’t detect the CharacterCloneDisplay, then it just breaks the rest of the code. If I place it at the end of the script, then when the next time another script clones and places the CharacterCloneDisplay, it is destroyed. How can I write something that works better?

Do:

if workspace:FindFirstChild("CharacterCloneDisplay") then
    workspace.CharacterCloneDisplay:Destroy()
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.