Problem with pet following the player

Hi devs, i wantedo to do a pet following system.

I have a problem, some pets are glitched in the ground and some are under the map.

This is the part of the script:

local PetPositions = {
	{Position = Vector3.new(1,4,6), Orientation = Vector3.new(0, -90, 0)},
	{Position = Vector3.new(1,4,6), Orientation = Vector3.new(0, -120, 0)},
	{Position = Vector3.new(1,4,6), Orientation = Vector3.new(0, -60, 0)}
}

local function GetPetOrder(character: Model)
	local petFolder = character.Pets
	if #petFolder:GetChildren() == 0 then
		return 1
	end
	
	local activeSlots = {}
	for _, pet in ipairs(petFolder:GetChildren()) do
		local order = pet.Order.Value
		activeSlots[order] = order
	end
	
	for avaibleSlot = 1,5,1 do
		if not activeSlots[avaibleSlot] then
			return avaibleSlot
		end
	end
end

local function PetFollow(player: Player, pet:Instance)
	local character = player.Character
	if not character then return end
	
	local petsFolder = character:FindFirstChild("Pets")
	
	if not petsFolder then
		petsFolder = Instance.new("Folder", character)
		petsFolder.Name = "Pets"
	end
	
	local petModel: Model = ReplicatedStorage.Pets:FindFirstChild(pet.ID.Value):Clone()
	petModel:PivotTo(character.HumanoidRootPart.CFrame)
	
	local characterAttachment = Instance.new("Attachment", character.HumanoidRootPart)
	characterAttachment.Visible = false
	
	local petAttachment = Instance.new("Attachment", petModel.PrimaryPart)
	petAttachment.Visible = false
	
	local alignPosition = Instance.new("AlignPosition", petModel.PrimaryPart)
	alignPosition.MaxForce = 30_000
	alignPosition.Attachment0 = petAttachment
	alignPosition.Attachment1 = characterAttachment
	alignPosition.Responsiveness = 25
	
	local alignOrientation = Instance.new("AlignOrientation", petModel)
	alignOrientation.MaxTorque = 30_000
	alignOrientation.Attachment0 = petAttachment
	alignOrientation.Attachment1 = characterAttachment
	alignOrientation.Responsiveness = 25
	
	local order = Instance.new("IntValue", petModel)
	order.Name = "Order"
	order.Value = GetPetOrder(character)
	
	petModel.Name = pet.Name
	petModel.Parent = petsFolder
	petModel.PrimaryPart:SetNetworkOwner(player)
	
	local petPosition = PetPositions[order.Value]
	characterAttachment.Position = petPosition.Orientation
	characterAttachment.Orientation = petPosition.Orientation
end

local function PetUnfollow(player: Player, petUUID: string)
	local character = player.Character
	if not character then return end
	
	local pet = character.Pets:FindFirstChild(petUUID)
	if not pet then return end
	
	pet:Destroy()
end

image

Thanks!

Turn off CanCollide for your pets and add to the position.

I already turned off the CanCollide before, but same problem

image