What's wrong with this lerp script?

Hello everyone! Recently I worked on creating an FPS with an FPS kit tutorial and I ran into a problem. I am using this lerp script to lerp from the just killed player to the player that killed them. Everything works really well except, when it finishes lerping, it doesn’t go back to the original camera. It’s stuck in a position where the killer’s head was. I get this warning: “RunService:UnbindFromRenderStep removed different functions with same reference name killcam 2 times.” Any suggestions?

repeat wait() until game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character.Parent ~= nil and game.Workspace.CurrentCamera

local runService = game:GetService(“RunService”)
local player = game.Players.LocalPlayer
local character = player.Character
local camera = game.Workspace.CurrentCamera

local TweenService = game:GetService(“TweenService”)
local player = game.Players.LocalPlayer
local CurrentCamera = workspace.CurrentCamera
runService:UnbindFromRenderStep(“killcam”)

game.ReplicatedStorage.KillCam.OnClientEvent:Connect(function(exploder)
script.Parent.Visible = true
script.Parent.Text = "Exploded by "…exploder

pcall(function()
	
		local alpha = 0.1 --0.5/2
		local startCFrame = camera.CFrame
	local killerChar = game.Workspace:FindFirstChild(exploder)
		camera.CameraType = Enum.CameraType.Scriptable
		runService:BindToRenderStep("killcam", 0, function()
			if killerChar and killerChar:FindFirstChild("Head") then
				local endcf = killerChar.Head.CFrame * CFrame.new(0, 3, 10)
				camera.CFrame = CFrame.new(camera.CFrame:lerp(endcf, alpha).p, killerChar.Head:GetRenderCFrame().p)
			
			wait(5)
			
			print("Findished with camera")

            runService:UnbindFromRenderStep("killcam")
            character = workspace:WaitForChild(game.Players.LocalPlayer.Name)
			script.Parent.Visible = false
			CurrentCamera.CameraSubject = game.Workspace:WaitForChild(game.Players.LocalPlayer.Name):WaitForChild("Humanoid")
			CurrentCamera.CameraType = Enum.CameraType.Custom
		end
	end)	
end)
end)
repeat wait() until game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character.Parent ~= nil and game.Workspace.CurrentCamera

local runService = game:GetService(“RunService”)
local player = game.Players.LocalPlayer
local character = player.Character
local camera = game.Workspace.CurrentCamera

local TweenService = game:GetService(“TweenService”)
local player = game.Players.LocalPlayer
local CurrentCamera = workspace.CurrentCamera
runService:UnbindFromRenderStep(“killcam”)

game.ReplicatedStorage.KillCam.OnClientEvent:Connect(function(exploder)
	script.Parent.Visible = true
	script.Parent.Text = "Exploded by "…exploder

	pcall(function()

		local alpha = 0.1 --0.5/2
		local startCFrame = camera.CFrame
		local killerChar = game.Workspace:FindFirstChild(exploder)
		camera.CameraType = Enum.CameraType.Scriptable
		runService:BindToRenderStep("killcam", 0, function()
			if killerChar and killerChar:FindFirstChild("Head") then
				local endcf = killerChar.Head.CFrame * CFrame.new(0, 3, 10)
				camera.CFrame = CFrame.new(camera.CFrame:lerp(endcf, alpha).p, killerChar.Head:GetRenderCFrame().p)
			end
		end)	
		wait(5)

		print("Finished with camera")

		runService:UnbindFromRenderStep("killcam")
		character = workspace:WaitForChild(game.Players.LocalPlayer.Name)
		script.Parent.Visible = false
		CurrentCamera.CameraSubject = game.Workspace:WaitForChild(game.Players.LocalPlayer.Name):WaitForChild("Humanoid")
		CurrentCamera.CameraType = Enum.CameraType.Custom

	end)
end)

It was likely because the script kept repeating itself (Everything past wait(5) was part of the renderstepped function, so I would assume that the script continued to do the rest until it ended up trying to remove “killcam” twice. I might be wrong though.

Ok thanks, I will try this. It sort of worked when I set the wait 5 to something like wait(2) because I have the respawn time set to 3 seconds. But I will try this and see if it works better. Thanks!