I currently have a ENT:Think function that repositions an entity when the owner dies, but when the owner dies the entity stays at the same spot. Here is the code:
local owner = self:GetOwner()
if ( IsValid(owner) ) and owner:Alive() == false then
for k,v in ipairs(ents.FindByClass("info_player_blue")) do
if !IsValid(v) then continue end
self:SetPos(v:GetPos() + Vector ( 40, 5, 0))
For you, PlayerDeath would be the right hook. So, when the player dies, it creates the entity and copies the bones; PlayerDeathThink is where you can limit respawning, and by using PlayerDeath you save yourself using a costly ents.Find* function in a Think hook…
Look at corpse.lua from TTT; it’ll show you how to copy the bones from the dead player to a ragdoll. You could freeze the ragdoll in place, or have it fall. Alternatively you could just spawn the entity there.