Hello, today I got a problem that say: “The parent property of jeb is locked, current parent: NULL, new parent: char0003sevitan”.
(jeb is a localscript and char0003sevitan is my player character) https://gyazo.com/5cbac64d29d84c7dbd9d884057788c1c
If it’s possible I would like to know how correct this error.
The reason the problem is happening is most likely due to the script not being initialized yet, thus throwing that warning. I think the error is not due to the object being destroyed.
There’s hundreds of lines of code which are creating and customizing a character, but I don’t know why? What are you trying to do with making a model? If you are trying to create a custom character, then you should make the model normally and name the model “StarterCharacter”, then parenting it to StarterPlayer. This would work way better, plus you could place your scripts in StarterCharacterScripts. If that’s not what you’re trying to do, then I would have to look at your code way more.
I used to have this problem it occurs when you clone something outside a function, and then parent it inside a function. Try bringing the clone if you have any at all, into the function
There are 2 methods that lets you delete the part, :Remove() and :Destroy().
:Remove() - method that sets the instance parent to nil, and does the same for all its descendants meaning it doesn’t really destroy it and it keeps all the connections etc.
:Destroy() method also sets the instance parent to nil and does the same for all its descendants but along with it, this method does everything to make the model as useless as if it didn’t exist. it e.g. disconnects part events.
However since :Remove method is just setting the instance and its descendants parent to nil, it doesn’t bother about parent locking.
:Destroy() method locks the parent property with the instance removal, so parent property has to be nil.
Additionally there are 2 better ways that you could try out to fix this problem:
if statement
check if the parent isn’t null before destroying objects.
local part
if part.Parent then
part:Destroy()
end
debris, debris service could do the checks for you, try it:
local debris = game:GetService("Debris")
local part
debris:AddItem(part, 0)
hello, probaly you are trying this UniversalNametag:Clone() UniversalNametag.Parent = char:FindFirstChild("Head") UniversalNametag.Username.Text = plr.Name, if it is the case, you need to define the clone like this: local clone = UniversalNametag:Clone() clone.Parent = char:FindFirstChild("Head") clone.Username.Text = plr.Name