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

Help with respawning?

How would I make this script below to respawn a character, but not set their health to 0?

script.Parent.MouseButton1Click:connect(function()
	local p = game.Players.LocalPlayer
	p.TeamColor = BrickColor.new("Medium stone grey")
end)

1 answer

✓ Accepted answer

Use the LoadCharacter method of their Player.

However, since this is a LocalScript, you're going to have to use something (preferably a Remote* object) to tell the Server to do this, as LoadCharacter should only be used from a Script:

--Server Script
local rs = Instance.new("RemoteEvent", Game:GetService("ReplicatedStorage"))
rs.Name = "Respawn"
rs.OnServerEvent:connect(function(player)
	player:LoadCharacter()
end)
--Local Script (added a debounce)
local rs = Game:GetService("ReplicatedStorage"):WaitForChild("Respawn")

local deb = false
script.Parent.MouseButton1Click:connect(function()
	if deb then return end
	deb = true --It doesn't close because I assume the PlayerGui gets reset.
	local p = game.Players.LocalPlayer
	p.TeamColor = BrickColor.new("Medium stone grey")
	rs:FireServer()
end)

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