--		if #all_height > 0 then
--			local avg
--			local sum = 0
--			for i=1,#all_height do
--				local _height = all_height[i]
--				sum = sum + _height
--			end
--			avg = sum / #all_height
--			height = avg
--		end

		
		return height
		
	end

	function Pets.Update()
		if Pets.Pet and Pets.Pet.Instance then
			local instance = Pets.Pet.Instance
			if Player.Character and Player.Character.PrimaryPart and Player.PetAttachment then
				local pet_type_data = PetData[Pets.Pet.Data.referenceModel]
				if pet_type_data and instance.PrimaryPart then
					local char_cf = Player.Character.PrimaryPart.CFrame
					local pet_cf = instance.PrimaryPart.CFrame
					local height = Pets:GetHeight(char_cf, instance) or pet_type_data.Offset.p.Y
					local new_cf = pet_type_data.Offset - Vector3.new(0,pet_type_data.Offset.p.Y,0) + Vector3.new(0,height,0)--char_cf:ToWorldSpace(pet_type_data.Offset - Vector3.new(0,pet_type_data.Offset.p.Y,0) + Vector3.new(0,height,0)) 
										
					Player.PetAttachment.CFrame = new_cf		
				end
			end
		end
	end

	Services.RunService.Heartbeat:Connect(Pets.Update)


return Pets
