Pet Jumping above raycasted position when using a sine animation

I’m currently working on a pet system and am having a problem with a jumping animation.

The pet seems to be floating or jumping above the raycasted ground position while walking, as if it’s walking mid air instead of on to the ground surface.

I’ve tried clamping the min to 0. And it worked. But the jumping looked really bad, when the pet was falling back down it had a heavy unrealistic landing

jump = math.abs(math.sin(t)) * config.jumpHeight -- jumpheight = 3 btw

local baseCFrame = CFrame.new(rootPart.Position.X, yPos + flyOffset + jump, rootPart.Position.Z)
local t = tick() * config.jumpSpeed -- Time-based progression for smooth animation
local groundYPos = yPos -- Raycast result for ground position

-- Compute jump offset using sin for smooth motion
local jumpOffset = math.sin(t) * config.jumpHeight

-- Avoid going below the ground by clamping the jump
local adjustedY = math.max(groundYPos + flyOffset, groundYPos + flyOffset + jumpOffset)

-- Smooth landing: Interpolate back to ground level
if jumpOffset < 0 then
    local landingSpeed = config.landingSmoothness or 0.2
    adjustedY = adjustedY + jumpOffset * landingSpeed
end

-- Final position for the pet
local baseCFrame = CFrame.new(rootPart.Position.X, adjustedY, rootPart.Position.Z)