BetterRespawn [V.1.1.0]

Introduction


In games meant for combat, you might die and respawn a lot. So why not respawn with flair?

BetterRespawn can do just that in one simple, short, commented, and configurable script. Choices like fading in, sizing up, and glowing, and others are present alongside options to configure how they work to your liking. It’s even easy to add custom-made effects yourself!

Better yet? It supports both R15 and R6!

Try it out


Download Model

Script
--[[

  ____       _   _              _____                                      
 |  _ \     | | | |            |  __ \                                     
 | |_) | ___| |_| |_ ___ _ __  | |__) |___  ___ _ __   __ ___      ___ __    v.1.1.0
 |  _ < / _ \ __| __/ _ \ '__| |  _  // _ \/ __| '_ \ / _` \ \ /\ / / '_ \      Supports R6 and R15!
 | |_) |  __/ |_| ||  __/ |    | | \ \  __/\__ \ |_) | (_| |\ V  V /| | | |
 |____/ \___|\__|\__\___|_|    |_|  \_\___||___/ .__/ \__,_| \_/\_/ |_| |_|
                                               | |                         
                                               |_|    
                                               
]]
---------------------------------------------------------------------------------------------------------------------------------------------------
local Configuration = {
	FadeInOnRespawn = true,
	--> Players will have a fading-in effect when they respawn.
	
	FadeTime = 2,
	--> How long the fade will last. (From FadeInOnRespawn)
	
	ScaleOnRespawn = true,
	--> Players will have a scaling up/growing effect when they respawn.
	
	ScaleTime = 2,
	--> How long the scaling will last. (From ScaleOnRespawn)
	
	LightEffectOnRespawn = true,
	--> Players will glow when they respawn.
	
	LightColor = Color3.fromRGB(255, 255, 255),
	--> Color for the light. (From LightEffectOnRespawn)
	
	RiseUpOnRespawn = true,
	--> Players will rise up a few studs (controlled by RiseUpStartPoint) from under where they spawn, like a zombie or ghost rising upwards from a grave.
	--> Works best with FadeInOnRespawn!
	--> A SpawnLocation is recommended.
	
	RiseUpStartPoint = 20,
	--> Controls how many studs under their spawn point the player starts at during the RiseUpOnRespawn effect.
	
	RiseUpEffectStuns = true,
	--> If set to true, while the player is rising up (from RiseUpOnRespawn), they won't be able to move. This is heavily recommended!
	
	RiseUpTurnsOnCollisions = true
	--> During the RiseUpOnRespawn effect, the players collisions are turned off. Set this to false if you want the players collisions to stay off after it ends.
}
---------------------------------------------------------------------------------------------------------------------------------------------------
local TweenService = game:GetService("TweenService")

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local HumanoidRootPart = Character.HumanoidRootPart
-------------------------------------------------------------------------------------------------------------------------------------------		
		if Configuration.FadeInOnRespawn then
			local FadeTweenInfo = TweenInfo.new(Configuration.FadeTime, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
			--> EasingStyle and Direction are customizable.
			
			for i,v in ipairs(Character:GetDescendants()) do
				if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
					--> HumanoidRootPart has to be exempt from the transparency tweening so it stays invisible.
					
					v.Transparency = 1
					local FadeTween = TweenService:Create(v, FadeTweenInfo, {Transparency = 0})
					FadeTween:Play()
				end
			end
		end
---------------------------------------------------------------------------------------------------------------------------------------------------		
		if Configuration.ScaleOnRespawn then
			local ScaleTweenInfo = TweenInfo.new(Configuration.ScaleTime, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out)
			--> EasingStyle and Direction are customizable.
			for i,v in ipairs(Character:GetDescendants()) do
				if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
					local ScaleTween = TweenService:Create(v, ScaleTweenInfo, {Size = v.Size})
					v.Size *= 0.5
					--> Start out at half size.
					
					ScaleTween:Play()
				end
			end
		end
---------------------------------------------------------------------------------------------------------------------------------------------------
		if Configuration.LightEffectOnRespawn then
			local Glow = Instance.new("PointLight")
			Glow.Name = "Glow"
			Glow.Color = Configuration.LightColor
			Glow.Parent = HumanoidRootPart
			Glow.Brightness = 5
			--> Brightness is customizable.
			
			local LightTweenInfo = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)

			local LightTween = TweenService:Create(Glow, LightTweenInfo, {Brightness = 0})
			LightTween:Play()
			
			LightTween.Completed:Connect(function()
				Glow:Destroy()
				--> If the player dies a lot and the lights from the past are still there, it might lag the server.
			end)
		end
---------------------------------------------------------------------------------------------------------------------------------------------------
		if Configuration.RiseUpOnRespawn then
			local RiseUpStuds = Configuration.RiseUpStartPoint
			
			local EndPosition = HumanoidRootPart.CFrame
			local StartPosition = EndPosition - Vector3.new(0, RiseUpStuds, 0)
			--> Simple calculation for where the player should start and end.
			
			local PastSpeed = Character.Humanoid.WalkSpeed
			local PastJump = Character.Humanoid.JumpPower
			--> Some games have faster default speeds, so I added this just in case.
			
			HumanoidRootPart.Anchored = true
			--> If we don't anchor the HumanoidRootPart, the player will start acting glitchy when tweened.

			if Configuration.RiseUpEffectStuns then
				Character.Humanoid.WalkSpeed = 0
				Character.Humanoid.JumpPower = 0
			end
			
			HumanoidRootPart.CFrame = StartPosition
			
			for i,v in ipairs(Character:GetDescendants()) do
				if v:IsA("BasePart") then
					v.CanCollide = false
				end
			end
			
			local RiseTweenInfo = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
			--> Customizable easing.
			
			local RiseTween = TweenService:Create(HumanoidRootPart, RiseTweenInfo, {CFrame = EndPosition})
			RiseTween:Play()
			
			RiseTween.Completed:Connect(function()
				if Configuration.RiseUpTurnsOnCollisions then
					for i,v in ipairs(Character:GetDescendants()) do
						if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
							--> The HumanoidRootPart should always be CanCollide false.
							v.CanCollide = true
						end
					end
				end
				Character.Humanoid.WalkSpeed = PastSpeed
				Character.Humanoid.JumpPower = PastJump
				HumanoidRootPart.Anchored = false
				--> Make sure to unanchor the HumanoidRootPart so the player can move.
			end)
		end
	end)
end)
---------------------------------------------------------------------------------------------------------------------------------------------------

How to use


Simply put the script into a place like ServerScriptService and you’re good to go! It’s that easy. Configuration is inside of the script.

You can also edit the easing and other small details in the source code.

9 Likes

Can you provide a demonstration on what this script does?

2 Likes

cool tip time!

for expressions such as v.Size = v.Size * 0.5 you can shorten them using *=

v.Size = v.Size * 0.5 becomes v.Size *= 0.5, you can also do this for other operations
like +=, -=, /=, ^= , which would be addition, subtraction, division, and exponents respectively

Theres also %= and ..= for the modulo and concat operators, I like using ..= like string.push() in ts

1 Like

After you die this happens:
image
Then u get ur body back
Very cool idea

1 Like

Yo can you add a zombie rising from grave respawn tyty <3

I am not the op wdym?..

Thanks! I knew += and -= but didn’t know those.

1 Like

Basically, on respawn you have effects. For example, instead of instantly being placed at a spawn point, you fade in.

ive added a rising up effect in the updated version that you can download! (v1.1.0)