(This is all assuming the attachLeftLeg function is apart of the local script GiveScript)
I’m not 100% sure on what’s causing this, but I do have an idea. Now I don’t know how much you know, so I’ll be pretty verbose when explaining my though process - sorry if any of this seems patronising or obvious, I don’t intend for it to be.
1) When a player equips a tool, it moves from the backpack to the character model (and vice versa for unequipping)
UNEQUIPPED
EQUIPPED
So the tool’s parent property is being changed.
2) When an instance, such as a tool, is being destroyed, it’s parent property is locked. If you try and change the parent property whilst it is locked, you will get the “trying to set locked parent!” warning.
So AFTER you seemingly destroy the tool in the attach left leg function, something must be setting the parent property. You said this yourself:
. It doesn’t set any references to nil because the LocalScript should destroy itself before it can
So here’s what I think is happening, you’re destroying the tool via a local script - this means that the tool is only destroyed for that client.
Here I am holding a tool, I have a local script such that when I activate it it destroys itself.
Sure enough it’s destroyed, but this is from the client’s view.
Switching over to the server view, we see the player still holding a tool (just without the animation)
So by destroying the tool locally, the server still thinks the tool exists. You can see this on the hierarchy (server side):
Then, when you pick up the second tool, ROBLOX must parent that tool to your model (as stated in 1, tools which are equipped are children of the character model) So it moves the older (seemingly destroyed tool) over to the backpack.
As stated earlier, it does this by setting the parent property, however, the local script believes the tool is destroyed (because it is destroyed locally), so it’s under the impression that a locked property is being changed - which causes the warning to show up.
Sorry if any of that was poorly explained. Point is, I was able to get the same warning message with the following setup:
- Tool with a local script, which when activated destroys itself (locally)
- I then walked over to another tool which I picked up (similar to the video you showed)
- The warning message showed up
If this is the cause of the issue (I’d suggest attaching the spring to your leg, then switching to the server view to see if your character is still holding the tool), you would need to destroy the tool on a server script instead. So use a remote event, which when fired tells the server to destroy the tool. Like I said earlier, I don’t know how much you know.