Cant make characters pelvis move up and down on ik foot placement

greetings, im making ik foot placement and im struggling with pelvis up and down movement like for day and i still cant fix it. can you help me please?

local Footstep_left_ik_raycast = workspace:Raycast(script.Parent.Ragdoll.Activator.LeftFoot.Position + Vector3.new(0,2,0),Vector3.new(0,-2.3,0),rayparams)

IKs.IK_LEFT_FOOTSTEP.Enabled = Footstep_left_ik_raycast ~= nil and Footstep_left_ik_raycast.Distance <= 2

if Footstep_left_ik_raycast and Footstep_left_ik_raycast.Distance <= 2.2 then
	LEFT_FOOTSTEP_TARGET.WorldPosition = Footstep_left_ik_raycast.Position + Vector3.new(0,0.2,0)
end

local Footstep_right_ik_raycast = workspace:Raycast(script.Parent.Ragdoll.Activator.RightFoot.Position + Vector3.new(0,2,0),Vector3.new(0,-2.3,0),rayparams)

IKs.IK_RIGHT_FOOTSTEP.Enabled = Footstep_right_ik_raycast ~= nil and Footstep_right_ik_raycast.Distance <= 2

if Footstep_right_ik_raycast and Footstep_right_ik_raycast.Distance <= 2.2 then
	RIGHT_FOOTSTEP_TARGET.WorldPosition = Footstep_right_ik_raycast.Position + Vector3.new(0,0.2,0)
end

local hipraycast = workspace:Blockcast(CFrame.new(humrootpart.CFrame.Position - Vector3.new(0,humrootpart.Size.X/2,0)) * humrootpart.CFrame.Rotation,humrootpart.Size,Vector3.new(0,-hum.HipHeight*2.3,0),rayparams)
if hipraycast then
	if not Footstep_left_ik_raycast or not Footstep_right_ik_raycast then
		var.currentwaistpos = math.clamp(var.currentwaistpos - 0.1,-1,1)
	else
		local averageFootHeight = (Footstep_left_ik_raycast.Position * Vector3.new(0,1,0) - Footstep_right_ik_raycast.Position * Vector3.new(0,1,0)).Magnitude

		var.currentwaistpos = math.clamp(averageFootHeight-hipraycast.Distance,-1,1)
	end
else
	var.currentwaistpos = math.clamp(var.currentwaistpos - 0.1,-1,1)
end
char.LowerTorso.Root.C1 = CFrame.new(0,-var.currentwaistpos + 0.1,0)

used math.abs on left leg and right leg positions and it works fine now