The problem is when the tool gets copied back to the Backpack of the player from the starterpack the character hasn’t been set to the new character yet, Player.Character still references the old character
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Root = Character:WaitForChild('HumanoidRootPart')
Root.Anchored = true
This simple script has problems, when parented to a tool inside starterpack. When the player resets the tool gets copied however the player object still holds the old reference. So when you spawn it makes your old character’s humanoid rootpart anchored and not yours.
Unfortunately there is no other easy way to get a character. This should not be happening in the first place, as when you respawn your Local Character becomes the newly created one.
You could reference the Player from parentage of the Backpack, but I don’t know of any other way to get characters, and you shouldn’t have to make any workarounds in the first place.
Normally the old character despawns before the new one appears. Do you have some kind of preservation of old character system?
I dont think so. Im a bit confused as to what you mean by “the old character”. If the tool is in starter pack, the local script in it shouldn’t have ran yet.
Because if you print the character it actually prints it, but when you print the parent it’s set to nil. That’s the old character reference. The reason I know this is because I tested it try this script and reset and put it in a tool:
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
print(Character, " Parent ", Character.Parent)
local Root = Character:WaitForChild('HumanoidRootPart')
Root.Anchored = true
As you see I do Player.CharacterAdded:Wait() or Player.Character, it doesn’t actually wait for the character to be added, that means Player.Character is not nil and the variable is set to it, making it have the old reference. (That’s how or works if the thing before it is not nil it sets it to the next thing in vairables)
No. I mean add the wait after the definition, but before the wait. That way we can tell if it has the new character, it just hasnt been parented to workspace yet.
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
wait(10)
print(Character, " Parent ", Character.Parent)
local Root = Character:WaitForChild('HumanoidRootPart')
Root.Anchored = true
This is why I think Player.Character holds the old reference before respawning. Let me test if this is true on the serverside.