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

Instantly re-spawn on death?

How can one make players instantly re-spawn on death?

1 comment

1

Just a note, but if you instantly respawn you won't even "seem" to die. The reason why most games don't do this is they'll just "teleport" to spawn like nothing happened.

2 answers

✓ Accepted answer

Using the Died event of humanoid and the LoadCharacter event of Player. You could do something like this:

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		local humanoid  = character:WaitForChild("Humanoid")
		humanoid.Died:connect(function()
			player:LoadCharacter()
		end)
	end)
end)

You can use LoadCharacter to force a player to spawn. If you run this function when the player dies there should be little to no delay in spawn time.

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(charModel)
		local hum = charModel:WaitForChild('Humanoid', 5) -- should make it safer
		if hum then
			hum.Died:Connect(function()
				plr:LoadCharacter() -- force a player to spawn ie no delay
			end)
		end
	end)
end)

I hope this helps.

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