Mirror's edge wall climbing + sliding

So, I’ve been trying to remake the mirror’s edge catalyst’s movement and I have come to the part where the player has the ability to climb up a wall a little bit and then slide down

My idea was to do raycast in front of the player to detect the wall, then boost the player up using body velocities, and then using body velocities again to create a slow fall effect.

The problem is I’ve tried that and the player just keeps glitching out.

this is my script currently

local char = script.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
local HRP:BasePart = char:WaitForChild("HumanoidRootPart")
local hum:Humanoid = char:WaitForChild("Humanoid")

local Speed = 2500
local Gravity = 5
local JumpPower = 50
local MaxWallrunRadius = 4
local CameraTiltAmount = 15
local Cooldown = 0.75

local momentumStep = 0.1
local momentumChangeEnabled = true

local baseSpd = 1
local maxSpd = 22
local animator:Animator = hum:WaitForChild("Animator")
local wra_R = animator:LoadAnimation(script.wr_R)
local wra_L = animator:LoadAnimation(script.wr_L)
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = {char}

local Attach = Instance.new("Attachment")
Attach.Parent = HRP

local Velocity = Instance.new("LinearVelocity")
Velocity.Visible = true
Velocity.Parent = HRP
Velocity.MaxForce = math.huge
Velocity.Enabled = false
Velocity.Attachment0 = Attach
Velocity.RelativeTo = Enum.ActuatorRelativeTo.World

local MaxWallrunRadius = 3.5

local WallNormal:Vector3
local Wallrunning
local WallClimbing
local Dir = 0

local Jump = script.Parent:WaitForChild("Jump")
local Shift = script.Parent:WaitForChild("Shift")

local Vaulting = false
local wcstp
local WallClimbSteps = 100
local Shifting = false

local Jumping = false
local Jumped
--debug 

Jump.OnServerEvent:Connect(function(plr,dir)
	Jumped = true

	if dir ~= 0 then
		Jumping = true

		if hum:GetState() ~= Enum.HumanoidStateType.Freefall then return end
		local wallL = workspace:Raycast(HRP.Position, (-1*HRP.CFrame.RightVector)*MaxWallrunRadius, params)
		if wallL then
			Dir = -1
			Wallrunning = true
			WallNormal = Vector3.new(wallL.Normal.Z, 0, -wallL.Normal.X)
			wra_L:Play()
		else
			local wallR = workspace:Raycast(HRP.Position, (1*HRP.CFrame.RightVector)*MaxWallrunRadius, params)
			if wallR then
				Dir = 1
				Wallrunning = true
				WallNormal = Vector3.new(wallR.Normal.Z, 0, -wallR.Normal.X)
				wra_R:Play()
			end
		end

	else
		wra_L:Stop()
		wra_R:Stop()
		Jumping = false
		Wallrunning = false
		Velocity.Enabled = false
		Velocity.VectorVelocity = Vector3.new(0, 0, 0)
		HRP.AssemblyLinearVelocity = Vector3.new(0, JumpPower, 0)

	end
end)

Shift.OnServerEvent:Connect(function(plr, bool)
	Shifting = bool


end)

hum.StateChanged:Connect(function(old,new)
	if new == Enum.HumanoidStateType.Landed then
		Jumped = false
		WallClimbing = false
	end
end)

game:GetService("RunService").Heartbeat:Connect(function(dt)
	--momentum builder
	if hum.MoveDirection ~= Vector3.new(0,0,0) then
		if Shifting then
			if hum.WalkSpeed < maxSpd then
				if momentumChangeEnabled then
					hum.WalkSpeed = hum.WalkSpeed + 1
					momentumChangeEnabled = false
					task.wait(momentumStep/5)
					momentumChangeEnabled = true
				end
			end
		else
			if hum.WalkSpeed < maxSpd then
				if momentumChangeEnabled then
					hum.WalkSpeed = hum.WalkSpeed + 1
					momentumChangeEnabled = false
					task.wait(momentumStep)
					momentumChangeEnabled = true
				end
			end
		end
	else
		if hum.WalkSpeed > baseSpd then
			hum.WalkSpeed = baseSpd
		end
	end



	--wall running
	if hum:GetState() ~= Enum.HumanoidStateType.Freefall and hum:GetState() ~= Enum.HumanoidStateType.FallingDown then Wallrunning = false end
	if Wallrunning then
		Velocity.Enabled = true
		local result = workspace:Raycast(HRP.Position, HRP.CFrame.RightVector*MaxWallrunRadius*Dir, params)
		if result then
			local v = WallNormal*Speed*-Dir*dt
			Velocity.VectorVelocity = Vector3.new(v.X, -Gravity, v.Z)

		else
			Wallrunning = false

		end
	elseif WallClimbing then
		Velocity.Enabled = true

		local result = workspace:Raycast(HRP.Position, HRP.CFrame.LookVector*MaxWallrunRadius*Dir, params)
		if result and wcstp >0  then
			local v = WallNormal*Speed*-Dir*dt
			Velocity.VectorVelocity = Vector3.new(v.X, 5, v.Z)
			wcstp -= 1
		else
			WallClimbing = false
			wcstp = 0 
		end
	elseif Velocity.Enabled then
		Velocity.Enabled = false
		Velocity.VectorVelocity = Vector3.new(0, 0, 0)
	end
	--vaulting and wall climbigr

	if Vaulting == false then
		local rayF = workspace:Raycast(char.HumanoidRootPart.CFrame.Position, char.HumanoidRootPart.CFrame.LookVector * 2 , params)
		local rayU = workspace:Raycast(char.HumanoidRootPart.CFrame.Position, (char.Head.CFrame.LookVector + char.Head.CFrame.UpVector) * 2 , params)


		local ray = rayF
		if rayF and rayU and WallClimbing == false then
			WallClimbing = true
			HRP.Anchored = true
			task.wait(0.05)
			HRP.Anchored = false
			local Vel = Instance.new("BodyVelocity")
			Vel.Parent = HRP
			Vel.Velocity = Vector3.new(0,0,0)
			Vel.MaxForce = Vector3.new(1,1,1) * math.huge
			Vel.Velocity = HRP.CFrame.UpVector * 50 
			wait(0.15)
			Vel:Destroy()
			task.wait(0.2)

			WallClimbing = false
			
		elseif rayF and rayU and WallClimbing == true and Jumped == true  then
			
			HRP.Anchored = true
			task.wait(0.05)
			HRP.Anchored = false
			local Vel = Instance.new("BodyVelocity")
			Vel.Parent = HRP
			Vel.Velocity = Vector3.new(0,0,0)
			Vel.MaxForce = Vector3.new(1,1,1) * math.huge
			Vel.Velocity = HRP.CFrame.UpVector * 5 
			wait(1)
			Vel:Destroy()
			task.wait(0.2)

			
			
		elseif rayF and rayU == nil and Jumping  then
			print(rayF,rayU)

			Vaulting = true
			HRP.Anchored = true
			task.wait(0.05)
			HRP.Anchored = false
			local Vel = Instance.new("BodyVelocity")
			Vel.Parent = HRP
			Vel.Velocity = Vector3.new(0,0,0)
			Vel.MaxForce = Vector3.new(1,1,1) * math.huge
			Vel.Velocity = HRP.CFrame.LookVector * 50 + Vector3.new(0,50,0) 
			wait(0.15)
			Vel:Destroy()
			task.wait(0.2)

			Vaulting = false

		

		end
	end



end)

to note, im using a linear velocity for wall running and a separate body velocity for vaulting

if someone will help me that will be really appreciated!