Backflip script messing with the camera

I’ve recently made a backflip script and it’s messing with the camera… I can’t really find a fix myself so I came here.

Roblox Studio - Clipped with Medal.tv this video shows the problem I’m having with the camera basically targeting an invisible mass instead of the character, yes the camerasubject is the humanoidrootpart

function EndFlip(KeybindFlipType)
– .025 : 9 dg (self note, time to degree ratio)

CurrentlyPressing = nil

Type.Visible = false
StudsTravel.Visible = false
Type.Text = "Flip Type: none"
StudsTravel.Text = "Studs: none"

local XRot = 9

local TravelAmountForward = Travelling / 40
local TravelAmountUp = Travelling / 160

Travelling = 0

if KeybindFlipType == BackflipKeybind then
	XRot *= -1
	TravelAmountForward *= -1
end

local HRP = game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character.PrimaryPart

if not HRP then return end

local OrgCFrame = HRP.CFrame

local function forccamera(HRP)
	workspace.CurrentCamera.CameraSubject = HRP
	workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
	workspace.CurrentCamera.FieldOfView = 70
end

forccamera(HRP)

HRP.Anchored = true

for Repeat = 1, 40 do
	if not HRP then return end
	if Repeat == 21 then TravelAmountUp *= -1 end

	HRP.CFrame = HRP.CFrame * CFrame.Angles(math.rad(XRot),math.rad(0),math.rad(0))
	OrgCFrame = OrgCFrame * CFrame.new(Vector3.new(0,TravelAmountUp,TravelAmountForward))

	HRP.Position = OrgCFrame.Position

	forccamera(HRP)

	task.wait(0.025)
end

workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.PrimaryPart
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
workspace.CurrentCamera.FieldOfView = 70

HRP.Anchored = false

end

and ^ that is the function for doing the flip

( sorry for the bad formatting )