Is it better to do this instead of while true do

function chickengrease()
task.wait()
if workspace:findFirstChild(‘Bob’) then
workspace.Bob:Destroy()
end
chickengrease()
end

instead of something like

while task.wait() do
if workspace:findFirstChild(‘Bob’) then
workspace.Bob:Destroy()
end
end

What are trying to do? Delete something if something else is added? If so then there is a better way to do this. Also please format your scripts so they are easier to see and modify.

Not trying to do anything it’s just an example, code isn’t very long and I typed it on here that’s why it’s not formatted. Nothing is needed to be modified, I’m asking if the first method is better than while true do

1 Like

the top code uses recursion and the bottom code uses a loop

so I would do the bottom code, it is made for something like this

well just a tip
findFirstChild is deprecated
use FindFirstChild instead

1 Like