Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

When doing :Destroy on a tool it breaks. How do I fix this?

Asked by 6 years ago

Let's say I wanna delete a tool when I unequip my tool.

tool = script.Parent
tool.Unequipped:Connect(function()
tool:Destroy()
end)

See that would work in most cases because is my other game it works but in my new game it doesn't. In output an orange/yellow message appears:

** Something unexpectedly tried to set the parent of Tool to NULL while trying to set the parent of Tool. Current parent is Backpack. **

I've also tried more options like deleting it from Backpack via :FindFirstChild but that sends the same message too.

Please help me.

1 answer

Log in to vote
0
Answered by
Elixcore 1337 Moderation Voter
6 years ago

this means it's happening in the exact same tick, to fix this simply add a wait() before destroying it.

0
Thank you so much. TechGamar 30 — 6y
Ad

Answer this question