How to find HumanoidRootPart after death?

Ah, thank you!
For some reason the chunkFlush doesn’t seem to be working, can you spot an issue?:

while task.wait(chunkUpdateTime) do
	for charNum, char in pairs(characters) do
		coroutine.resume(chunkFlush, char)
	end
end
local chunkFlush = coroutine.create(function(char)
		
	local success, hrootPos = pcall(function()
		return char:WaitForChild("HumanoidRootPart", 2).Position
	end)
		
	if success then
		-- do thing
    end
end)
local players = game:GetService("Players")

local rootpartcheck = coroutine.create(function()
	while true do
		task.wait(2)
		for i, player in players:GetPlayers() do
			local rootpos = player:FindFirstChild("rootpartpos")
			if not rootpos then continue end
			local character = player.Character
			if not character then continue end
			local rootpart = character:FindFirstChild("HumanoidRootPart")
			if not rootpart then continue end
			rootpos.Value = rootpart.CFrame
		end
	end
end)
coroutine.resume(rootpartcheck)

players.PlayerAdded:Connect(function(player)
	local rootpartpos = Instance.new("CFrameValue")
	rootpartpos.Name = "rootpartpos"
	rootpartpos.Parent = player
end)


local function chunkFlush(player)
	local rootpos = player:FindFirstChild("rootpartpos")
	if rootpos then
		local position = rootpos.Value
		-- do as you wish with it's position
	else
		print("fail")
	end
end

while task.wait(chunkUpdateTime) do
	for charNum, char in pairs(characters) do
		local player = players:GetPlayerFromCharacter(char)
		chunkFlush(player)
	end
end
1 Like

Also keep in mind I’ve chosen to use CFrame, really the variable should be rootpartcframe not rootpartpos(a misnomer on my part). If you need it’s position you would just do rootpartcframe.Position

1 Like

No not starterplayerscripts, startercharacterscripts.

1 Like

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