"trying to set locked parent!" warning

This is an ongoing problem for some reason (it doesn’t show where the error is coming from)

The few posts I found while searching don’t have enough explanations for me to understand it

I made a part that creates a tool and then destroys itself. When the tool is picked up, it creates the error but still works fine. This doesn’t happen by any other means, for some reason

-- Despawn script inside the part (in a model)
task.wait(5)
local Item = game.ReplicatedStorage.Items.Consumables["TheItem"]:Clone()
Item.Parent = game.Workspace
Item.Handle.CFrame = script.Parent.CFrame
script.Parent.Parent:Destroy()

Screenshot 2023-05-13 185201

Anything helps thanks

1 Like

Apparently, from what I’ve seen, this error can come from the fact that destroy locks the object’s parent to nil, but in our case, you don’t use destroy on the same object and use destroy after, maybe it’s a bug since I also saw that it can also be that. I cannot help further I never seen this error.

1 Like

its prolly because ur destroying it right after u create it. try using debris maybe idk

1 Like

Converted all script.Parent:Destroy() to game.Debris:AddItem(script.Parent,1) but it still didn’t work

Thanks

what is ‘script.Parent.Parent’ ?

1 Like

The script is in a part which is in a model

script.Parent.Parent:Destroy() is to destroy the whole model

Please send the whole code. Perhaps the problem is elsewhere, but this is not visible because the code is not full.