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

How to lengthen respawn time for a character?

So I had a little trouble with this. Do I delete the default [if there is one] respawn script and replace it with a new one? I want to lengthen respawn time for good reasons.

So this is my attempt. Which is in the PlayerCharacterScripts.

respawnscript = script.Parent.Respawn
respawnscript:Destroy()

script.Parent.Humanoid.Died:connect(function()
	wait(20)
	-- Apparently I have to recreate the character??
	oldchr = --THIS IS WHERE IM STUCK?
	newchr = oldchr:Clone()
	newchr.Parent = workspace
	newchr:MoveTo(spawnpoint.Position) -- Dont mind spawnpoint value
	workspace.CurrentCamera.CameraSubject = newchr
end)

Also, if there is a function to automatically respawn a character, instead of manually removing the character, and cloning it and teleporting it to a random spawn, then please tell me!

1 answer

✓ Accepted answer

There is a way to automatically respawn a character, instead of manually removing the character

Instead of doing what you're doing, there's a property of the Players service called, CharacterAutoLoads. Turn this off.

Now you have to tell the player when to load it's character. To do this, you now have to use :LoadCharacter() on the player when you want to spawn/respawn their character.

You would want to spawn their character when they join, and after they die. An example script would look like this,

-- Script in ServerScriptService

local RespawnTime = 10

game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(char)
		char:WaitForChild("Humanoid").Died:wait()
		wait(RespawnTime)
		plr:LoadCharacter()
	end)

	wait(5)
	plr:LoadCharacter()
end)
Just make sure you turn off CharacterAutoLoads.

That was my script. For the wiki's script, look here.

Good Luck!

If I helped, please don't forget to accept my answer.

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