I’m trying to position my pet so it’s actually along the ground. I’m encountering several problems. Main one being it ain’t even on the floor. But even if I got to other elevations it stays in the same Y pos

BodyGyro and BodyPosition have default properties on them, and are located inside the Red part
local function Follow()
if not CurrentPet then return end
-- Wait for Hitbox
local PetHitbox = CurrentPet:WaitForChild("Hitbox")
-- Get Body's
local BodyGyro = PetHitbox.BodyGyro
local BodyPosition = PetHitbox.BodyPosition
Render = RunService.RenderStepped:Connect(function()
local Character = Player.Character
if not Character then return end
local HumanoidRootPart = Character.HumanoidRootPart -- Get HumanoidRootPart
-- Check if player is 15 studs away from pet
local Distance = (HumanoidRootPart.Position - PetHitbox.Position).Magnitude
if Distance < 15 then return end
-- If so, we want to keep moving the pet, until the player has come to a complete stop
while Character.Humanoid.MoveDirection ~= Vector3.new(0, 0, 0) do
-- Cast ray
local RaycastFilter = RaycastParams.new()
RaycastFilter.FilterType = Enum.RaycastFilterType.Blacklist
RaycastFilter.FilterDescendantsInstances = {CurrentPet}
local RaycastResult = workspace:Raycast(CurrentPet.Hitbox.Position, Vector3.new(0, -20, 0), RaycastFilter)
if not RaycastResult then return end
local FloorPosition = RaycastResult.Position.Y
local TopSurface = FloorPosition + (RaycastResult.Instance.Size.Y / 2) -- Add 1/2 Y size so it gets very top surface
local BoundSize = CurrentPet.Hitbox.Size.Y --
local YPos = TopSurface
-- Set Body's
BodyGyro.CFrame = HumanoidRootPart.CFrame
BodyPosition.Position = Vector3.new(HumanoidRootPart.Position.X, YPos, HumanoidRootPart.Position.Z)
wait()
end
end)
end
Follow()