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

How do I make a player respawn instantly?

So I've made this script:

script.Parent.Touched:connect(function(part)
	if part.Parent and game:GetService('Players'):GetPlayerFromCharacter(part.Parent) then
		local player = game:GetService('Players'):GetPlayerFromCharacter(part.Parent)
		if player:GetRankInGroup(3200799) < 300 then
			local humanoid = part.Parent:FindFirstChild("Humanoid")
			humanoid.Health = 0
			end
	end
end)

but I want the player to respawn instantly, how do I do that?

2 comments

0

listen to the died event (from humanoid), set characterautoloads (option in players) to false, and do player:LoadCharacter()

1 answer

✓ Accepted answer

You can use the function LoadCharacter to force the player to respawn.

local plrServ = game:GetService('Players')
script.Parent.Touched:connect(function(hit)
	local plr = plrServ:GetPlayerFromCharacter(hit.Parent)
	if plr and plr:GetRankInGroup(3200799) < 300 then
		plr:LoadCharacter()
	end
end)

I hope this helps

2 comments

0

Thank you

0

game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(chr) repeat wait() until chr.Humanoid chr.Humanoid.Died:connect(function() plr.LoadCharacter() end) end) end)?

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