I've made a destroy button, that when clicked, destroyes all of something called "Bread". Doesn't seem to work :/
local cd = game.Workspace["ClearBread Button"].Button.BreadRemover
local found = workspace:FindFirstChild("Bread")
script.Parent.MouseClick:connect(function()
while true do
if found then
found:Destroy() --destroy everything called "Bread"
wait(1)
cd.Parent.BrickColor = BrickColor.new("Really red") -- make the button red
cd.Parent = game.Workspace --unparents it so it can't be clicked again
wait(20) --cooldown time
cd.Parent = game.Workspace["ClearBread Button"].Button --reparents it
cd.Parent.BrickColor = BrickColor.new("Forest green") --changes button back
wait(.1)
end
end)
The explorer looks a little like this:
ClearBread Button --Model
Button --Part
BreadRemover --ClickDetector
Script --The script I just posted
Please help me out if you can, I'll accept your answer if it works or you find an alternative way to make it work C:
(In case you need to know, I only want the Bread in Workspace to be destroyed, I have another "Bread" in ReplicatedStorage which I do NOT want to be Destroyed)
