Instance:Destroy() not working

If you don’t know how Debris Service works, here is the link for you: Debris | Roblox Creator Documentation

Unfortunately, it works in the same manner as Instance:Destroy(), so I don’t think it’ll have any effect.

1 Like

This would lead me to believe that the clone is destroyed, but the original object is still in-game as all three print statements are reached.

True, I think the cloned knife should be named to plr.Name…“'s Knife” (Exam: Tidyen’s Knife) so you can use pairs() to destroy it.

I don’t see how a name change would work? The script has a reference to the clone, by which it’s calling :Destroy() on it.

I know that, just saying if it helps with the issue.

The idea you’re suggesting here could work, but we’d need to find the object using a function such as :WaitForChild(‘knifeClone’):Destroy(), which I don’t really see it being a solution knowing that it could be destroyed with the already existing reference.

perhaps try something along the lines of

local runservice = game:GetService("RunService")
coroutine.wrap(function()
    while knifeClone do
        knifeClone:Destroy()
        runservice.Stepped:Wait()
    end
end)()

Doesn’t work :/.
Still extremely confused as to why this is happening.

Are you certain that the cloned object is the object you’re seeing not be destroyed? I’m not sure what to do at this point as you did state the all three print statements did print earlier after the destroy call.

On the ROBLOX api reference, it says this:
`
Tip: After calling Destroy on an object, set any variables referencing the object (or its descendants) to nil. This prevents your code from accessing anything to do with the object.

  1. local part = Instance.new(“Part”)
  2. part.Name = “Hello, world”
  3. part:Destroy()
  4. – Don’t do this:
  5. print(part.Name) → “Hello, world”
  6. – Do this to prevent the above line from working:
  7. part = nil

Once an Instance has been destroyed by this method it cannot be reused because the Instance.Parent property is locked. To temporarily remove an object, set Parent it to nil instead. For example:
`
I also believe I read somewhere that destroying an object on the server doesn’t destroy it’s decendants on the client or something like that…

I had the same question, I currently use it to detect if any response is received from a client if I have to call :InvokeClient().

He probably says that because of this article. Not sure if it’s completely true tho. Delay isn’t that harmful anyway

Try to use debris instead, debris is pretty useful :smiley:

I don’t know exactly, but a lot of the pros say it. Something to do with the task scheduler.

After attempting to both add the cloned knife to DebrisService AND setting knifeClone = nil in the same test (Along with adding a part to an earlier check that asks whether knifeClone exists) it still doesn’t work. For testing purposes I decreased cooldown from 5 seconds to .5 seconds and it still doesn’t get destroyed.

did you try this?

Debris:AddItem(Knife, .5) 

That’s exactly what I tried, except Knife is knifeClone (what i want to destroy) and .5 is cooldown (which itself is defined as .5)

For some strange reason, the last statement here is correct. Upon checking the server, I saw that the knives were completely gone. A different version of the knife was being displayed, of which was a child of the knife on the client. What reason does this have to happen? It only serves to complicate and confuse.

Now the question is, how do we delete it off the client? I attempted to send a remote event over to the client to tell it to destroy the dang thing, but it just won’t work! THIS KNIFE DOESN’T WANT TO DIE!

alright so I figured it out…
a thing on the client was cloning the knife and when I deleted that code it worked perfectly
this is what I get for following outdated tutorial code.