Cant find HumanoidRootPart after Death

After a character dies the script is not able to find the hrp. Even if I put a :WaitForChild on it it yields infinitely. I’ve searched for the topic before posting and I couldn’t find any case where the solution isnt somthing I haven’t tried or unrelated to my problem, here’s my code:

local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local hrp = Character:WaitForChild("HumanoidRootPart") -- I used to have Character.HumanoidRootPart but neither work

These are the first Lines of a script and I have a Humanoid.Died:Connect() function later but it does unrelated stuff and the error Studio sends traces back to Line 4. For some reason it reruns the entire script after a player dies and cant find the hrp. Thanks in advance

If I’m understanding you correctly, I had a similar problem a while back:

1 Like

Ik it looks really weird but try this

local hrp = (function()
	repeat task.wait() until char:FindFirstChild("HumanoidRootPart")
	return char.HumanoidRootPart

Basically its a lambda function that waits for the humanoidrootpart to exist and then gives it to you, and u can use it the same way u would use it normally, like

hrp.Position =,69,69)

Try local hrp = Humanoid.RootPart.

what even is this? please remove this comment😅

Actually, maybe you don’t even need to specify the humanoid root part if you can just do Humanoid.RootPart every time,…

Humanoid.RootPart is not a thing mate, there are no baseparts in Humanoid

only the Character model has baseparts

You sure? Did you even check?

yeah you are right but that does say torso instead of HumanoidRootPart. is that just something with characteers that are R6?

My character is old and does not have a HumanoidRootPart which is why it said Torso, but for yours it should say HumanoidRootPart.

yes I am sure that has nothing to do with the hrp of the character (and also both r6/r15 have hrps)

You sure? Did you even check?

and yeah basically, the rootpart in Humanoid (which is just an attribute/property) which is basically the PrimaryPart of the character, which in most cases is humanoidrootpart (I think all cases even) , unless it’s a custom character

You are only getting the character on the start of the script. When the character dies it gets removed and when it loads back your script still has your old character.

To fix this you have to update the character using the player.CharacterAdded event or something else you might think of.

1 Like

I’ve found the solution by putting the entire scirpt in a player.CharacterAdded:Connect function after
local player = game.Players.LocalPlayer

Thanks to everyone who tried to help, I’ll mark this as a solution in case anybody ever has the same problem I had (The script was in StarterPack btw)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.