How would I go around making this system work

Basically what I need to do is when the player dies, they get sent into a dimension where their body is lying on the floor (where they died) and their astral form comes out. I’m unsure on how to get around this, if any help could be provided that would be amazing.

How would I set it up?
And all that stuff - I have tried on a previous attempt but failed three times.

local players = game:GetService("Players")
local charPos = CFrame.new(0, 0, 0)

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character:SetPrimaryPartCFrame(charPos)
		local hmr = character:WaitForChild("HumanoidRootPart")
		local humanoid = character:WaitForChild("Humanoid")
		--add code here
		humanoid.Died:Connect(function()
			charPos = hmr.CFrame
		end)
	end)
end)

This will teleport a player to where they died (I’ve commented where you will need to add code to achieve your desired goal of the player lying down and a spirit being released from them).