Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Problem with HumanoidRootPart After Death?

I've made an automatic door opener, and it works perfectly until I die. When I die it stops working and when I spawn in this error come Infinite yield possible on 'Workspace.Zelt3q:WaitForChild("HumanoidRootPart". Any ideas why? Thanks.

while wait() do
	local plrs = game.Players:GetPlayers()

	for i, plr in pairs(plrs) do
		local char = plr.CharacterAdded:Wait()
		local HRP = char:WaitForChild("HumanoidRootPart")

		if not HRP then return end

		local magnitude = (HRP.Position - sensor.Position).magnitude

		if magnitude < 15 then
			if isOpen then return end
			isOpen = true

1 answer

✓ Accepted answer

You need to detect when the player dies and then get the NEW HumanoidRootPart, this is because when the character dies it removes the whole character, and because this is on a while loop it confuses itself because it is waiting for a part that doesn't exist.

I hope my explanation helped, and here is a link to Humanoid.Died on the developer forum.

Have a great day, happy coding, Raie.

This discussion is preserved as it was. New answers, comments, and votes are closed.